0

I have the following .htaccess file setup to rediect all my .co.uk site traffic to the sites new .com domain name.

# 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

However I want to redirect .co.uk/blog to the new .com/blog however, at the moment, all that happens is when you visit .co.uk/blog it redirects to the .com homepage. - I believe this is because of;

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

How would I add a condition to overrule this if the URL ends /blog?

4

1 に答える 1

1

実際、最初のルールは に作成.co.ukされ.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
于 2013-10-02T10:03:05.283 に答える