htaccess * .php到* .html对象未找到错误 [英] htaccess *.php to *.html object not found error
问题描述
我正在尝试将URL从index.php
转换为index.html
,将servicii.php
转换为servicii.html
,依此类推.
I am trying to transform URLs from index.php
to index.html
, servicii.php
to servicii.html
and so on.
我在我的.htaccess
文件中写了文件,该文件位于我的网站中,其根代码如下:>
I wrote in my .htaccess
file, which is in my site root the following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.php$ $1.html [R=permanent]
</IfModule>
?>
但是,当我按照"Prima pagina"(首页)或"Servicii"(网站上仅有的两页)进行操作时,会出现404错误
But when I follow "Prima pagina" (Home) or "Servicii" (the only 2 pages created on site) it gives me a 404 error
我也有代码
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /fetesti/
RewriteRule ^(.*)\.php$ $1.html [R=permanent]
</IfModule>
在基于XAMPP的本地计算机上
.它使我找不到Object 404,并在我的Apache日志中:
on my local machine, which is XAMPP based. It gives me Object not found 404, and on my Apache log:
找不到文件[...]/index.html;
file not found [...]/index.html;
我知道重写引擎正在工作(我写了乱码,它使我看到505内部服务器错误并进行了其他测试)
I know the rewrite engine is working (I wrote gibberish and it gave me 505 internal server error and made other tests)
我在做什么错了?
推荐答案
尝试仅删除[R]永久重定向,并在规则中切换扩展名
Try just remove [R] permanent redirect, and switch extensions in rule
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.html$ $1.php
</IfModule>
这篇关于htaccess * .php到* .html对象未找到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!