【发布时间】:2017-06-06 10:28:32
【问题描述】:
我正在尝试使用Apache24 server 的mod_rewrite 模块,但我无法加载它。我知道有很多关于这个话题的问题,我已经解决了所有问题,但似乎没有任何效果。这些是我到目前为止所遵循的步骤---
- CHANGED
httpd.conf文件进行了这些更改--
一个。取消注释LoadModule rewrite_module modules/mod_rewrite.so
b.将AllowOverride None 更改为AllowOverride All
但在执行完所有这些步骤后,我无法在 phpinfo 中看到 mod_rewrite 作为已加载模块。
如上图所示,没有加载 mod_rewrite 模块。
同样作为一个疯狂的黑客,我什至尝试使用.htaccess 文件重写 URL,但这不起作用。 Apache 似乎忽略了 .htaccess 文件,尽管我已将该文件放在我的根目录中。
Note: I am running `PHP` as an apache module
Using `WAMP` stack
Using `localhost` as server
我非常需要这个模块来重写 URL。你们能建议一些其他方式来加载这个模块吗?
在过去的两天里,我一直在头疼。您认为需要重新安装还是与路径依赖性有关。任何建议将不胜感激。
编辑
我试图从虚拟主机重写 URL,因为答案表明模块已加载,它既不依赖于 .htaccess 也不依赖于 info.php。但它仍然没有重定向。我在下面添加Virtual host 设置---
<VirtualHost *:80>
<Directory "/Apache24/htdocs">
Options FollowSymLinks
AllowOverride All
DirectoryIndex index.html index.php
</Directory>
ServerName localhost
DocumentRoot "/Apache24/htdocs"
ErrorLog "/Apache24/logs/error.log"
CustomLog "/Apache24/logs/access.log" combined
<directory "/Apache24/htdocs">
<IfModule rewrite_module>
Options +FollowSymlinks
RewriteEngine On
</IfModule>
<IfModule rewrite_module>
RewriteRule ^working.php fun.html
</IfModule>
</directory>
# Rewrite Rules #####################
RewriteEngine On
RewriteRule ^working.php fun.html
# end Rewrite Rules #################
</VirtualHost>
当我尝试运行 fun.html 时,上面的代码不会将其重定向到 working.php。它只是说the requested URL /working.php was not found on this server.。
提前致谢!
【问题讨论】:
-
error.log 中是否有任何错误?
-
错误日志中没有错误。
标签: php apache .htaccess mod-rewrite httpd.conf