1

我已经搜索并尝试了几种可能的解决方案。

我开始:

http://example.com/729/start-page.asp?cid=4004  
http://example.com/729/start-page.asp?cid=7916

并尝试:

http://example.com/ johns-start-page  
http://example.com/judys-start-page

或者如果可能的话:

http://johns-start-page.example.com/  
http://judys-start-page.example.com/

到目前为止,我有:

重写引擎开启
重写条件 %{QUERY_STRING} ^cID=4004$  
RewriteRule ^729\.asp$ /johns-start-page [NC,R=301,L]

重写条件 %{QUERY_STRING} ^cID=7916$  
RewriteRule ^729\.asp$ /judys-start-page [NC,R=301,L]
4

1 回答 1

2

只要您对这些东西进行硬编码,您就可以尝试:

RewriteEngine On

RewriteCond %{THE_REQUEST} \ /+729/start-page.asp\?cid=4004($|\ |\&)
RewriteRule ^ /johns-start-page? [L,R=301]

RewriteCond %{THE_REQUEST} \ /+729/start-page.asp\?cid=7916($|\ |\&)
RewriteRule ^ /judys-start-page? [L,R=301]

RewriteRule ^johns-start-page$ /729/start-page.asp?cid=4004 [L,QSA]
RewriteRule ^judys-start-page$ /729/start-page.asp?cid=7916 [L,QSA]

对于子域,您需要确保已设置 DNS 以将这些子域指向相同的 IP 地址。然后是这样的:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^johns-start-page\.example\.com$ [NC]
RewriteCond %{THE_REQUEST} \ /+729/start-page.asp\?cid=4004($|\ |\&)
RewriteRule ^ http://johns-start-page.example.com/? [L,R=301]

RewriteCond %{HTTP_HOST} !^judys-start-page\.example\.com$ [NC]
RewriteCond %{THE_REQUEST} \ /+729/start-page.asp\?cid=7916($|\ |\&)
RewriteRule ^ http://judys-start-page.example.com/? [L,R=301]

RewriteCond %{HTTP_HOST} ^johns-start-page\.example\.com$ [NC]
RewriteRule ^$ /729/start-page.asp?cid=4004 [L,QSA]

RewriteCond %{HTTP_HOST} ^judys-start-page\.example\.com$ [NC]
RewriteRule ^$ /729/start-page.asp?cid=7916 [L,QSA]

但是,除非您将它们设置为包含 FQDN,否则您的所有链接都可能会中断。

于 2015-09-04T18:41:10.867 回答