【问题标题】:htaccess *.php to *.html object not found errorhtaccess *.php to *.html object not found 错误
【发布时间】:2012-05-19 06:09:09
【问题描述】:

我正在尝试将 URL 从 index.php 转换为 index.htmlservicii.php 转换为 servicii.html 等等。

我在我的.htaccess 文件中写了以下代码:

<IfModule mod_rewrite.c>  
    RewriteEngine On  
    RewriteBase     /
    RewriteRule     ^(.*)\.php$   $1.html [R=permanent] 
</IfModule> 
?>

但是当我关注“Prima pagina”(主页)或“Servicii”(在网站上创建的仅有的 2 个页面)时,它给了我一个 404 错误

另外,我有代码

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase  /fetesti/
    RewriteRule  ^(.*)\.php$   $1.html [R=permanent] 
</IfModule>

在基于 XAMPP 的本地计算机上。它给了我找不到对象 404,并在我的 Apache 日志中:

找不到文件 [...]/index.html;

我知道重写引擎正在工作(我写了乱码,它给了我 505 内部服务器错误并进行了其他测试)

我做错了什么?

【问题讨论】:

  • 您能否将您的代码格式化为代码块,以便我们轻松阅读?它有很大帮助。谢谢

标签: mod-rewrite http-status-code-404


【解决方案1】:

尝试删除 [R] 永久重定向,并在规则中切换扩展

<IfModule mod_rewrite.c>  
    RewriteEngine On  
    RewriteBase     /
    RewriteRule     ^(.*)\.html$   $1.php
</IfModule> 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-12
    • 2018-12-29
    • 2011-11-29
    • 2016-08-21
    • 2019-12-10
    • 1970-01-01
    • 2021-12-27
    • 2016-10-05
    相关资源
    最近更新 更多