2013-10-02 147 views
0

我有以下的.htaccess文件設置,以重新設置我的所有.co.uk網站流量到網站new .com域名。.htaccess - 條件條件?

# Redirect all requests NOT made under www.domain.com 
RewriteCond %{REQUEST_URI} !/admin 
#RewriteCond %{HTTP_HOST} !^www\.domain-name\.com [NC] 

#RewriteRule ^(.*)$ http://www.domain-name\.com/$1 [R=301,L] 

RewriteCond %{HTTP_HOST} !^www\.domain-name\.com 

RewriteRule (.*) http://www.domain-name.com/$1 [R=301,L] 

RewriteCond %{REQUEST_FILENAME}  !-d 

RewriteCond %{REQUEST_FILENAME}  !-f 

RewriteRule ^(.+) index.php?seo_path=$1&%{QUERY_STRING} [L] 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ 

RewriteRule ^index\.php$ http://www.domain-name.com/ [R=301,L] 

ErrorDocument 404 /page-not-found.php 

但是我想.co.uk /博客重定向到新的.com /博客然而,此刻,所有的情況是,當您訪問.co.uk /博客重定向到.COM主頁。 - 我相信這是因爲;

RewriteRule ^(.+) index.php?seo_path=$1&%{QUERY_STRING} [L] 

如果URL結束/博客,我會如何添加一個條件來否決此?

回答

1

其實你的第一條規則是讓01​​到.com需要跳過後續規則/blog

讓你的規則是這樣的:

# if request_uri doesn't start with /blog or /admin 
RewriteCond %{REQUEST_URI} !^/(admin|blog) [NC] 
RewriteCond %{HTTP_HOST} !^(www\.)?domain-name\.com$ [NC] 
RewriteRule^http://www.domain-name.com%{REQUEST_URI} [R=301,L] 

RewriteCond %{REQUEST_FILENAME}  !-d 
RewriteCond %{REQUEST_FILENAME}  !-f 
RewriteRule ^(.+)$ /index.php?seo_path=$1 [L,QSA] 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php[\s?] [NC] 
RewriteRule^http://www.domain-name.com/ [R=301,L] 

ErrorDocument 404 /page-not-found.php