【问题标题】:renaming a url is not working with htaccess重命名 url 不适用于 htaccess
【发布时间】:2013-10-19 11:18:58
【问题描述】:

我正在使用以下重写规则来重命名 url:-

RewriteRule ^home$ index.php

但这不起作用。所以我使用了另一个规则,即

RewriteRule ^home.html$ index.php

它正在显示404 error

注意:相同的代码在其他站点中运行,但在我的站点中没有。 谢谢!!

【问题讨论】:

  • 是否启用了 mod_rewrite?那是你的完整 htaccess 吗?
  • 不,我不知道,请告诉我你在哪里 chk 它,它在线,我不知道在 cpanel 哪里 chk,服务器是 apache
  • @SumeetMathew 如果您希望得到任何帮助,我建议您使用普通英语而不是某些 txtspeak。另外:请 GOOGLE 如何查看 mod_rewrite 是否启用。

标签: .htaccess url url-rewriting


【解决方案1】:

确保在您的规则之前打开mod_rewrite

RewriteEngine on
RewriteBase /

RewriteRule ^home(\.html?)?$ index.php [NC,L]

这会将/home/home.htm/home.html 重写为index.php。如果这不起作用,请检查您的 httpd.conf 文件中是否启用了 mod_rewrite(删除之前的 #)

LoadModule rewrite_module modules/mod_rewrite.so

在任何地方将 AllowOverride None 更改为 AllowOverride All。重启 Apache。

【讨论】:

    猜你喜欢
    • 2016-01-02
    • 1970-01-01
    • 2015-01-28
    • 2018-05-16
    • 2018-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多