问题:你想将特定的URL的请求重定向都其他服务器上。比如我有两个网站,网站A:www.site1.com,网站B:www.site2.com。当我在网站A中想用网站B的图片,但是不想用网站B的网址。从用户体验和SEO的角度来说,同一个网站的内容,应该统一才好。
解决方法:在httpd.conf文件中使用Redirect指令,并在第二个参数中设定绝对路径的URL.
Redirect “/example” “http://www2.example.com/new/location”
参数说明
temp:临时重定向(302重定向)
permanent:永久重定向(301重定向)
gone:不在此位置上(曾经存在)
seaother:被其他的文件代替(303重定向)
我的解决案例:
<IfModule alias_module>
#
# Redirect: Allows you to tell clients about documents that used to
# exist in your server’s namespace, but do not anymore. The client
# will make a new request for the document at its new location.
# Example:
# Redirect permanent /foo http://localhost/bar
Redirect permanent “/hotel-imgages” “http://www.hoteltour.cn/media/upload/hotel”
……
ScriptAlias /cgi-bin/ “cgi-bin/”
</IfModule>
说明:
这是在当前服务器的所有网站中,包含有“/hotel-imgages”的URL,都会映射到http://www.hoteltour.cn/media/upload/hotel
如图1:这是原始的,域名A上,用了域名B的文件。

图2:这是做了映射只后,网页的域名和图片域名统一了。
