我正在尝试使用带有mod_rewrite的Apache2进行简单的重定向。我在我的Apache中安装了模块,我在localhost / file1 / file2 / page.html中设置了一个网页。我在我的000默认文件中写这个:
RewriteEngine On
RewriteRule elegantdirectory/page.html file1/file2/page.html [L,NC]
所以现在如果我尝试访问localhost / elegantdirectory / page.html,服务器应该向我显示我在file1 / file2中的page.html。任何想法为什么不工作?
答案 0 :(得分:0)
尝试在RewriteRule
中包含边界和前导斜杠:
RewriteRule ^/elegantdirectory/page.html$ /file1/file2/page.html [L,NC]