合并网站并重定向旧网址

时间:2015-09-24 16:05:17

标签: .htaccess mod-rewrite url-redirection

我们合并了2个网站,并且必须从现在尚未使用的域中组织重定向。

域名aquarestaurantblackheath.co.uk重定向很好,但不是该域名中的旧网址。

任何建议。看我的代码......

工作

RewriteCond %{HTTP_HOST} ^aquarestaurantblackheath\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.aquarestaurantblackheath\.co\.uk$
RewriteRule ^/?$  "http\:\/\/www\.aquabarandgrill\.co\.uk\/section\/3\/1\/restaurant\-blackheath" [R=301,L]

不工作

RewriteCond %{HTTP_HOST} ^aquarestaurantblackheath\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.aquarestaurantblackheath\.co\.uk$
RewriteRule ^section\/8\/1\/location$ "http\:\/\/www\.aquabarandgrill\.co\.uk\/section\/10\/1\/restaurant" [R=301,L]

RewriteCond %{HTTP_HOST} ^aquarestaurantblackheath\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.aquarestaurantblackheath\.co\.uk$
RewriteRule ^section\/6\/1\/wines$ "http\:\/\/www\.aquabarandgrill\.co\.uk\/section\/8\/1\/food\-wine\-blackheath" [R=301,L]

RewriteCond %{HTTP_HOST} ^aquarestaurantblackheath\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.aquarestaurantblackheath\.co\.uk$
RewriteRule ^section\/7\/1\/reservations$ "http\:\/\/www\.aquabarandgrill\.co\.uk\/section\/3\/1\/restaurant\-blackheath" [R=301,L]

整个htaccess:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^aquabarandgrill.co.uk [NC] 
RewriteRule ^(.*)$ http://www.aquabarandgrill.co.uk/$1 [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ 
RewriteRule ^index\.php$ http://www.aquabarandgrill.co.uk/ [R=301,L] 
RewriteRule ^index\.html$ http://www.aquabarandgrill.co.uk/ [R=301,L] 
RewriteRule ^index\.htm$ http://www.aquabarandgrill.co.uk/ [R=301,L] 

RewriteEngine on
Options +SymlinksIfOwnerMatch +MultiViews
RewriteRule ^(.*).php/(.*) $1.php?$2

## Bromley old site REDIRECTS (PERMANANT 301) ##

RewriteRule ^Home.php?id=Menus/?$ http://www.aquabarandgrill.co.uk/section/2/1/restaurant-bromley/ [L,R=301,NC]

#
## Deafult character encoding UTF-8 / ISO-8859-1
AddDefaultCharset ISO-8859-1

RewriteEngine On

RewriteCond %{HTTP_HOST} ^aquarestaurantblackheath\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.aquarestaurantblackheath\.co\.uk$
RewriteRule ^/?$ "http\:\/\/www\.aquabarandgrill\.co\.uk\/section\/3\/1\/restaurant\-blackheath" [R=301,L]

RewriteCond %{HTTP_HOST} ^aquabrasseriecroydon\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.aquabrasseriecroydon\.com$
RewriteRule ^/?$ "http\:\/\/www\.aquabarandgrill\.co\.uk\/section\/4\/1\/restaurant\-croydon" [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?aquarestaurantblackheath\.co\.uk [NC]
RewriteRule ^(/?|section/7/1/reservations)$ http://www.aquabarandgrill.co.uk/section/3/1/restaurant-blackheath [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?aquarestaurantblackheath\.co\.uk [NC] 
RewriteRule ^section\/8\/1\/location$ http://www.aquabarandgrill.co.uk/section/10/1/restaurant [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?aquarestaurantblackheath\.co\.uk [NC]
RewriteRule ^section\/6\/1\/wines$ http://www.aquabarandgrill.co.uk/section/8/1/food-wine-blackheath [R=301,L]

1 个答案:

答案 0 :(得分:1)

请尝试以下规则:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?aquarestaurantblackheath\.co\.uk [NC]
RewriteRule ^(/?|section/7/1/reservations)$  http://www.aquabarandgrill.co.uk/section/3/1/restaurant-blackheath [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?aquarestaurantblackheath\.co\.uk [NC]    
RewriteRule ^section/8/1/location$ http://www.aquabarandgrill.co.uk/section/10/1/restaurant [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?aquarestaurantblackheath\.co\.uk [NC]
RewriteRule ^section/6/1/wines$ http://www.aquabarandgrill.co.uk/section/8/1/food-wine-blackheath [R=301,L]

<击>

修改

看到整个htaccess文件后,删除其中的所有内容,并用以下代码替换整个文件:

AddDefaultCharset ISO-8859-1
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?aquarestaurantblackheath\.co\.uk [NC]
RewriteRule ^(/?|section/7/1/reservations)$  http://www.aquabarandgrill.co.uk/section/3/1/restaurant-blackheath [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?aquarestaurantblackheath\.co\.uk [NC]    
RewriteRule ^section/8/1/location$ http://www.aquabarandgrill.co.uk/section/10/1/restaurant [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?aquarestaurantblackheath\.co\.uk [NC]
RewriteRule ^section/6/1/wines$ http://www.aquabarandgrill.co.uk/section/8/1/food-wine-blackheath [R=301,L]

RewriteRule ^(.*)\.php/(.*) $1.php?$2 [L]