我是第一次使用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被重写...有什么想法吗?
更新::所有的事情都解决了。上述所有设置都应输入到/etc/apache2/sites enable/000-default文件中。
已解决
更新:
我刚刚尝试了非常简单的重写规则。我已经在我的web服务器根目录中创建了test1.html和test2.html文件。然后我在我的httpd.conf文件中写下了以下规则
RewriteRule ^test1\.html$ test2.html 当我访问test1.html时,浏览器仍然显示test1.html文件,而不是test2.html/请帮助..我在过去的三天里遇到了这个麻烦...受够了..:-(
发布于 2011-03-16 03:51:46
你写的是你希望它重定向到http://example.com/index.php?id=/anything/after/this,但是你却重定向到了http://example.com/storage-server/index.php?id=/anything/after/this。会是这样吗?
发布于 2012-04-08 15:14:53
确保Apache的httpd.conf中的以下行未被注释掉
LoadModule rewrite_module模块/mod_rewrite.so
https://stackoverflow.com/questions/5317087
复制相似问题