Forum Moderators: phranque
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine OnRewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
However, when I make redirects, the subfolders (addon domains) are affected too, for example:
[blah.com...] redirects to [abc.dom...]
How do I make a rewrite condition and rule that only works for the main domain?
I've tried adding:
# Rewrite /index.html to /index.php for abc.com only
RewriteCond %{HTTP_HOST} ^(www\.)?abc\.com
RewriteRule ^index\.html$ /index.php [L]
RewriteCond %{HTTP_HOST} ^(www\.)?blah\.com
RewriteRule .* - [L]
I thought it worked for a second.
Here's what I have:
#This commented code didn't work either
#RewriteCond %{HTTP_HOST} ^(www\.)?blah\.com
#RewriteRule .* - [L]# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# I expect this to ignore the following rule if it's for blah.com
RewriteCond %{HTTP_HOST}!^(www\.)?blah\.com
RedirectMatch permanent ^/index.html$ http://www.abc.com/index.php
RewriteCond %{HTTP_HOST} ^(www\.)?blah\.com
RewriteRule .* - [L]
I expect it to ignore everything below it, especially the:
RedirectMatch permanent ^/index.html$ http://www.abc.com/index.php which is further down. But I get the same problem: www.blah.com/index.html will redirect to www.abc.com/index.php
[edited by: jdMorgan at 3:17 am (utc) on Feb. 8, 2007]
[edit reason] formatting clean-up [/edit]
If you replace it with
RewriteRule ^index\.html$ http://www.abc.com/index.php [R=301,L]
Each Apache module in turn parses your .htaccess file, executing only the directives that it understands. As such, very little 'communication' is available between these modules, and the order of directives from different modules in your code has no effect on the order in which they will be processed. Rather, directives all of the same module will be processed in order, but the directives from differing modules will be processed in the order that those modules execute -- as determined by the inverse LoadModule order on Apache 1.x, and by an internal priority scheme on Apache 2.x.
Jim