Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite making subdomains search engine friendly

         

logi

9:33 pm on Jul 18, 2005 (gmt 0)

10+ Year Member



I'm currently trying to make a subdomain of mine search engine friendly and I am having troubles...

This currently gives an Internal Server Error(500).

RewriteEngine On
RewriteCond %{HTTP_HOST} sub\.domain\.com
RewriteCond %{REQUEST_URI}!^sub/
RewriteRule ^([A-Za-z]+)?/?([A-Za-z]+)?/?([A-Za-z]+)?/? /sub/index.php?1=$1&2=$2&3=$3

For reference: my subdomain was made with cPanel, and my .htaccess is placed in my public_html folder.

jdMorgan

12:12 am on Jul 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



logi,

Welcome to WebmasterWorld!

The critical problem is in your second RewriteCond. The REQUEST_URI is the entire URL path requested by the client, not the local URL-path "seen" by RewriteRule. Therefore, it must start with a slash. Since you don't have a slash, it will never match, and the rewrite will be invoked repeatedly, adding "/sub" to the URL again and again, until the server reaches its maximum internal redirection limit.


RewriteEngine On
RewriteCond %{HTTP_HOST} sub\.domain\.com
RewriteCond %{REQUEST_URI} !^/sub/
RewriteRule ^([a-z]+)?/?([a-z]+)?/?([a-z]+)?/? /sub/index.php?1=$1&2=$2&3=$3 [NC,L]

Note [NC,L] flags added for efficiency. See RewriteRule flags documentation for more info.

If you still have problems, examine your server error log; It often will tell you exactly what is wrong.

Jim