繁体   English   中英

使用htaccess将目录重定向到URL

[英]Using htaccess to redirect a directory to URL

我想使用.htaccess重定向以下任何一项:

http://domain.com/folder
http://domain.com/folder/
http://domain.com/folder/index.html
http://domain.com/folder/index.php

http://another-domain.com/file.php?var=xyz

我确实了解如何重写文件到文件或文件夹到文件夹,但是我缺少如何从文件夹重定向到其他域的文件URL

谢谢

通过httpd.conf启用mod_rewrite.htaccess ,然后将此代码放入DOCUMENT_ROOT/.htaccess文件中:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^folder(/.*|)$ http://another-domain.com/file.php?var=xyz [L,NC,R=301]

建议阅读: Apache mod_rewrite简介

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM