1

我需要使用新域将特定 URL(带有结构)重定向到相同的 URL,而不是其他 URL。

domainA.com/company/careers*

domainB.com/company/careers*

原因是第 3 方供应商提供了一个基于 jquery 的 iframe 应用程序,该应用程序在加载前执行引荐来源检查。

我意识到有一个更大的 seo/重复内容问题需要解决,但是在 domainA.com 完全重定向到 domainB.com 之前需要做很多额外的工作,所以现在,它只是“职业”部分。

该站点使用 IIS6 和 HeliconTech 的 ISAP ReWrite3

http://www.helicontech.com/isapi_rewrite/doc/introduct.htm

当前规则:

# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.59

<VirtualHost www.domainA.com www.domainB.com> 

RewriteEngine On 

#RewriteBase /
#RewriteRule ^pubs/(.+)\.pdf$ /404/?pub=$1.pdf [NC,R=301,L]

# Send away some bots
RewriteCond %{HTTP:User-Agent} (?:YodaoBot|Yeti|ZmEu|Morfeus\Scanner) [NC] 
RewriteRule .? - [F]

# Ignore dirctories from FarCry Friendly URL processing
RewriteCond %{REQUEST_URI} !(^/measureone|^/blog|^/demo|^/_dev)($|/) 
RewriteRule ^([a-zA-Z0-9\/\-\%:\[\]\{\}\|\;\<\>\?\,\*\!\@\#\$\ \(\)\^_`~]*)$ /index.cfm?furl=$1 [L,PT,QSA] 

RewriteCond %{REQUEST_URI} ^/company/careers [NC]
RewriteRule ^company/careers/?(.*)$ http://www.domainname.com/company/careers/$1 [R=301,L]

# Allow CFFileServlet requests
RewriteCond %{REQUEST_URI} !(?i)^[\\/]CFFileServlet


RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /blog/index.php [L]

</VirtualHost> 

<VirtualHost blog.domainA.com> 

RewriteEngine On 

#redirect old blog.domainA.com/* posts to www.domainB.com/blog/*
RewriteCond %{HTTP_HOST} ^blog.domainA\.com [nc]
RewriteRule (.*) http://www.domainB.com/blog$1 [R=301,L]


</VirtualHost> 
4

2 回答 2

1

只需检查请求是否以/company/careers

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/company/careers [NC]
RwriteRule ^company/careers/?(.*)$ http://domainB.com/company/careers/$1 [R=301,L]

看看这是否适合你。

于 2015-02-12T19:21:47.010 回答
1

似乎“RewriteBase /blog/”行破坏了您的“职业”规则,因为它暗示请求应该是 domainA.com/blog/company/careers*

请考虑这样:

<VirtualHost www.domainA.com www.domainB.com> 

RewriteEngine On 
RewriteBase /
#RewriteRule ^pubs/(.+)\.pdf$ /404/?pub=$1.pdf [NC,R=301,L]

# Send away some bots
RewriteCond %{HTTP:User-Agent} (?:YodaoBot|Yeti|ZmEu|Morfeus\Fucking\Scanner) [NC] 
RewriteRule .? - [F]

# Ignore dirctories from FarCry Friendly URL processing
RewriteCond %{REQUEST_URI} !(^/measureone|^/blog|^/demo|^/_dev)($|/) 
RewriteRule ^([a-zA-Z0-9\/\-\%:\[\]\{\}\|\;\<\>\?\,\*\!\@\#\$\ \(\)\^_`~]*)$ /index.cfm?furl=$1 [L,PT,QSA] 

RewriteCond %{REQUEST_URI} ^/company/careers [NC]
RewriteRule ^company/careers/?(.*)$ http://www.domainname.com/company/careers/$1 [R=301,L]

# Allow CFFileServlet requests
RewriteCond %{REQUEST_URI} !(?i)^[\\/]CFFileServlet

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/.* /blog/index.php [L]

</VirtualHost> 

如果您仍然有问题,请通过输入启用登录 httpd.conf

RewriteLogLevel 9

并检查您的请求是如何在 rewrite.log 中处理的。

于 2015-02-13T08:23:31.660 回答