如果这很简单,我很抱歉。我已经用谷歌搜索了它,但无济于事。
我正在运行 Ubuntu 9.04、Jaunty Jackelope 和 Apache2。经过一番麻烦,我终于启用了 mod_rewrite,我的 .htaccess 文件正在尝试做这件事,但失败了。这是我的设置。
在/etc/apache2/conf.d/我有一个名为apeace-public-html.conf 的文件。内容如下:
# makes /home/apeace/public_html/ available through /localhost/apeace
Alias /apeace /home/apeace/public_html/
在/home/apeace/public_html/我有以下 .htaccess 文件:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^test\.html$ index.html
同样在/home/apeace/public_html/我有一个名为 index.html 的文件,但我没有一个名为 test.html 的文件。在我看来,当我尝试访问 http://localhost/apeace/test.html 时,这个重写应该显示 index.html .但是,这是我得到的错误:
Not Found
The requested URL /home/apeace/public_html/index.html was not found on this server.
所以问题是,我到底做错了什么?
非常感谢。
-和平
最佳答案
在这里只是一个猜测,但你能尝试让 RewriteRule 像 ^test.html$/apeace/index.html
从错误消息来看,它似乎正在翻译` http://localhost/apeace/test.html至http://localhost/home/apeace/public_html/index.html
关于apache - .htaccess mod_rewrite 规则在 Ubuntu 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1692081/