apache - .htaccess mod_rewrite 规则在 Ubuntu 中不起作用

标签 apache mod-rewrite ubuntu

如果这很简单,我很抱歉。我已经用谷歌搜索了它,但无济于事。

我正在运行 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.htmlhttp://localhost/home/apeace/public_html/index.html

关于apache - .htaccess mod_rewrite 规则在 Ubuntu 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1692081/

相关文章:

php - .htaccess 使文件夹充当根目录?

wordpress - 限制对 WordPress LEMP 堆栈中文件管理器插件的访问

python - 为 python GUI 应用程序授予 root 权限以在 ubuntu 中运行命令

即使使用与其他域一起使用的 DocumentRoot,Apache 也会导致 403 禁止

apache - 使用 htaccess 将所有流量重定向到裸域 SSL

apache - 许多 Apache 进程生成速度非常快,最多可在 3 分钟内达到极限

.htaccess - 将 web.config 文件转换为 .htaccess

linux - Neo4j 警告 : Max 1024 open files allowed, 建议至少 40 000。请参阅 Neo4j 手册

linux - apache Mod_rewrite 关闭,wordpress 开心,404 我不开心

apache - 将旧子域重定向到新子域