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