Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Exclude Subdomain from root htaccess Rewrite



7:11 pm on Sep 17, 2010 (gmt 0)

5+ Year Member


I am running a script in my root that has the following htaccess code. It is interfering with Wordpress which is running in a subdomain on the same server. How can I limit this htaccess code so that it does not interfere with the operation of Wordpress. I did not write the code. It comes with the script. Thanks for the help!


RewriteRule \.(css|php|png|jpg|gif|ico|js|inc|txt|gz|xml|html)$ - [NC,L]
RewriteRule ^([^/]*)/?$ index.php?page=$1 [L]
RewriteRule ^([^/]*)/([^/]*)/?$ index.php?$1=$2 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ index.php?page=$1&$2=$3 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$ index.php?$1=$2&$3=$4 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$ index.php?page=$1&$2=$3&$4=$5 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$ index.php?$1=$2&$3=$4&$5=$6 [L]


11:49 pm on Sep 17, 2010 (gmt 0)

10+ Year Member

Are the subdomain and domain pointing to the same physical directory on your server?

Anyway, without knowing your server and sub-/domain configs, you could prevent any interferences by putting this line before each RewriteRule:

RewriteCond %{HTTP_HOST} !^sub\.example\.com$

which tells apaches mod_rewrite module not to follow the following rule if the domain host is your subdomain.


7:46 pm on Sep 18, 2010 (gmt 0)

5+ Year Member


Thanks much. It worked.

Yes, the domain and subdomain are on the same server hosted on Hostgator.


Featured Threads

Hot Threads This Week

Hot Threads This Month