即使在mod_rewrite之后,apache也会返回404

时间:2011-03-15 19:43:03

标签: mod-rewrite apache2

我第一次使用apache mod_rewrite。 我希望将http://example.com/anything/after/this转换为http://example.com/storage-server/index.php?id=/anything/after/this

我在apache的httpd.conf文件中写了以下几行

RewriteRule ^/(.*) /storage-server/index.php?id=$1

但我收到404消息说该文件不存在。我已启用mod_rewrite,因此不会出现问题。我认为有些事情阻止了这个URL被重写.... 任何想法???

UPDATE :: 一切都解决了。所有上述设置都应输入/ etc / apache2 / sites-enable / 000-default file ..

解决

UPDATE :::

我刚试过非常简单的重写规则。我在我的Web服务器根目录中创建了test1.html和test2.html文件。然后我在我的httpd.conf文件中写了以下规则

RewriteRule ^test1\.html$ test2.html 

当我访问test1.html时,浏览器仍然显示test1.html文件而不是test2.html /请帮助..我从最近3天起就遇到了这个麻烦...生病了...: - (

2 个答案:

答案 0 :(得分:0)

您写道,您希望它重定向到http://example.com/index.php?id=/anything/after/this,但您要重定向到http://example.com/storage-server/index.php?id=/anything/after/this。可能是吗?

答案 1 :(得分:0)

确保Apache的 httpd.conf 中的以下行未被注释掉

LoadModule rewrite_module modules / mod_rewrite.so