0

我们已经重建我们的网站,并正在寻找重定向约1000 的URL。看起来在网络上似乎httpd.conf 301重定向格式,服务器托管多于一个域名

Redirect 301 /oldlocation http://www.domain2.com/newlocation 

是要使用的字符串。我只是想知道服务器如何知道域名 /oldlocation,因为它承载多个网站。如果我们有两个 网站/oldlocation都将被重定向?

是否有可能使用

Redirect 301 http:full-old-url http:new-url 

代替,以确保服务器知道旧的URL,我们的目标?

+0

将您的.htaccess文件放在您需要的域的文件夹中,或者将其配置到配置文件的相关服务器块中。 [这是一个SO问题,解释如何使用虚拟主机完成此操作。](http://stackoverflow.com/questions/10175513/mod-rewrite-in-vhosts-configuration) – samiles

回答

0

在重定向指令的模式中,您可以匹配URI(主机名后的url部分),而不是主机。要匹配HOST,您需要使用mod-rewrite。

RewriteEngine on 

RewriteCond %{HTTP_HOST} example1.com 
RewriteRule ^/?oldpath http://example2.com/newpath [L,R=301] 

上面的例子都将请求重定向从example1.com/oldpathexample2.com/newpath

+0

完美!非常感谢你的回答,非常感谢。 – Makkie