没有更改域的重定向URL

时间:2013-08-09 12:19:50

标签: .htaccess url redirect url-rewriting

我有一台服务器,其IP地址(比方说)w.x.y.z,并且有2个域停在其上。

mydomain.com

herdomain.com

我还有3个文件管理器(php autoindex free),如下所示:

mydomain.com/Files/index.php?dir=folder1/folder2/

herdomain.com/myfiles/index.php?dir=mydata/folder2/

现在我想将打开folder2(来自上述网址之一)的用户重定向到此网址而不更改域名(是否可能)?

w.x.y.z/support/index.php?dir=mainfolder/folder2/

如何在autoindex或.htaccess上执行此操作?

由于

1 个答案:

答案 0 :(得分:1)

将此内容添加到网络根目录中的.htaccess“/”

RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^(mydomain|heredomain)\.com$ [NC]
RewriteCond %{QUERY_STRING} dir=(folder1|mydata)/folder2/ [NC]
RewriteRule ^(.*)$ http://w.x.y.z/support/index.php?dir=mainfolder/folder2/ [L]