.htaccess 重写模式不起作用
.htaccess 中的重写脚本
RewriteEngine on
RewriteRule ^index/page/(.*)$ index.php?page=$1
它适用于本地计算机。但在服务器中它不起作用。有人可以帮助我吗?
rewrite script in .htaccess
RewriteEngine on
RewriteRule ^index/page/(.*)$ index.php?page=$1
It works in local machine. but in server it does not work. can any body help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否已验证您的服务器上是否已加载重写模块?如果服务器正在运行 apache,您应该能够通过
在响应中查找 rewrite_module 来验证这一点。 (注意:您可能需要apachectl,具体取决于您使用的计算机。)
如果未加载,您可能需要更改服务器配置。这是可行的(同样,取决于所使用的 apache 版本),只需执行以下步骤
或确保您的 httpd.conf 文件包含
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
或确保存在符号链接在 rewrite.load 文件 /etc/apache2/mods-enabled 和 /etc/apache2/mods-available 之间。
之后不要忘记重新启动 apache。
Have you verified that the rewrite module is loaded on your server? If the server is running apache you should be able to verify this with
and looking for the rewrite_module in the response. (NB: You may need apachectl depending on the machine you are using.)
If it is not loaded you might need to change your server configuration. This is doable (again, depending on the version of apache in use) with a step like
or ensuring your httpd.conf file contains
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
or by ensuring there's a symbolic link between the rewrite.load file /etc/apache2/mods-enabled and /etc/apache2/mods-available.
Don't forget to restart apache afterwards.