将特定但通配符 * URL(带文件夹))重定向到新域(相同结构)

Redirect a specifc but wild card * URL (with folder(s)) to new domain (same structure)

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

域名A.com/company/careers*

域 B.com/company/careers*

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

我意识到有一个更大的 seo/duplicate 内容问题需要解决,但是在 domainA.com 完全重定向到 [=34= 之前还需要做很多额外的工作] 所以现在,它只是 "career" 部分。

该网站正在使用 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=.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= [L,PT,QSA] 

RewriteCond %{REQUEST_URI} ^/company/careers [NC]
RewriteRule ^company/careers/?(.*)$ http://www.domainname.com/company/careers/ [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 [R=301,L]


</VirtualHost> 

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

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

看看是否适合你。

似乎 "RewriteBase /blog/" 行破坏了您的 "careers" 规则,因为它暗示请求应该是域 A。com/blog/company/careers*

请考虑这样:

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

RewriteEngine On 
RewriteBase /
#RewriteRule ^pubs/(.+)\.pdf$ /404/?pub=.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= [L,PT,QSA] 

RewriteCond %{REQUEST_URI} ^/company/careers [NC]
RewriteRule ^company/careers/?(.*)$ http://www.domainname.com/company/careers/ [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 中的处理方式。