简体   繁体   中英

All RewriteCond domains go through the second default RewriteRule

UPDATE: All RewriteCond domains go through the second default RewriteRule, instead of going to their own RewriteCond, then RewriteRule. All URL's that I go to default to the /template/home.php. I know you can put in multiple domains in a single .htaccess, but I have not been able to get this .htaccess to direct different domains to their default paths. This has left me scratching my head.

Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} (.[^\.]+)(.+)(firstDomain)(\..+) [NC]
RewriteRule .* - [E=SLUG:%1,E=DOMAIN:%{HTTP_HOST}]
RewriteRule ^/?$ /template/home.php [NC,L,QSA]

RewriteCond %{HTTP_HOST} (.[^\.]+)\.on\.(secondDomain)(\..+) [NC]
RewriteRule .* - [E=SLUG:%1,E=DOMAIN:%{HTTP_HOST}]
RewriteRule ^/?$ /template/landing.php [NC,L,QSA]

What happends when you negate the first condition like this :

Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} (.[^\.]+)(.+)(firstDomain)(\..+) !^www.secondDomain.com$ [NC] 
RewriteRule ^/?$ /template/home.php [NC,L,QSA]

RewriteCond %{HTTP_HOST} (.[^\.]+)\.on\.(secondDomain)(\..+) !^www.firstDomain.com$  [NC]
RewriteRule ^/?$ /template/landing.php [NC,L,QSA]

RewriteCond is applicable to very next RewriteRule only. So you will need to have:

Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} (.[^\.]+)(.+)(firstDomain)(\..+) [NC]
RewriteRule ^ - [E=SLUG:%1,E=DOMAIN:%{HTTP_HOST}]

RewriteCond %{HTTP_HOST} firstDomain\. [NC]
RewriteRule ^/?$ template/home.php [L]

RewriteCond %{HTTP_HOST} (.[^\.]+)\.on\.(secondDomain)(\..+) [NC]
RewriteRule ^ - [E=SLUG:%1,E=DOMAIN:%{HTTP_HOST}]

RewriteCond %{HTTP_HOST} secondDomain\. [NC]
RewriteRule ^/?$ template/landing.php [L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM