【发布时间】:2016-02-01 18:27:29
【问题描述】:
我正在玩弄 .htaccess 文件,完全出于好奇,我想知道是否可以将对 .htaccess 文件本身的访问重定向到另一个文件?
例子:
用户转到http://www.example.com/.htaccess
我希望将用户重定向到index.php?foo=bar
我尝试了以下方法:
Redirect 301 /.htaccess /index.php?foo=bar
和
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^((?s).*)$ index.php?foo=bar [QSA,L]
</IfModule>
这些方法适用于任何其他文件,但 .htaccess 文件本身总是会导致出现 403 Forbidden 页面。
这可能吗?如果不是,那为什么?
【问题讨论】:
标签: apache .htaccess mod-rewrite redirect apache2