2013-10-02 188 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