簡體   English   中英

所有RewriteCond域都通過第二個默認RewriteRule

[英]All RewriteCond domains go through the second default RewriteRule

更新:所有RewriteCond域都通過第二個默認RewriteRule,而不是先進入自己的RewriteCond,然后再進入RewriteRule。 我默認使用的所有URL是/template/home.php。 我知道您可以在單個.htaccess中放入多個域,但是我無法獲得此.htaccess來將不同的域定向到其默認路徑。 這讓我撓頭。

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]

當您否定第一個條件時會發生什么:

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僅適用於下一個RewriteRule 因此,您需要具備:

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]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM