将下载目录重定向到子域

时间:2012-10-26 20:18:49

标签: apache .htaccess redirect

我的下载脚本结构是:

http://www.mysite.com/download/viewdownload/**/**

现在我想移动并重定向到子域

例如

重定向

http://www.mysite.com/download/viewdownload/61/4249
 to
http://www.alt.mysite.com/download/viewdownload/61/4249

http://www.mysite.com/download/viewdownload/53/824
 to
http://www.alt.mysite.com/download/viewdownload/53/824

1 个答案:

答案 0 :(得分:1)

您可以使用mod_alias:

Redirect /download/viewdownload http://www.alt.mysite.com/download/viewdownload

www.mysite.com主机的文档根目录中的vhost config或htaccess中,或使用mod_rewrite:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com$ [NC]
RewriteRule ^/?download/viewdownload/(.*)$ http://www.alt.mysite.com/download/viewdownload/$1 [L,R]