将扩展名html更改为php后,页面重定向

时间:2013-11-16 08:45:15

标签: php html html5boilerplate

我已将文件扩展名,HTML更改为PHP。当我在localhost中浏览时,它会被重定向到主服务器。我正在使用github,文件是使用带有twitter bootstrap的HTML5boilerplate开发的。我已经使用扩展HTML在github中提交了几个。 即 我之前的网址:[localhost]/sovolve.com/new/index.html 当前网址:[localhost]/sovolve.com/new/index.php

当我使用当前网址浏览localhost时,它会被重定向到http://sovolve.com/new/index.html

如果需要更新代码,请告诉我。

1 个答案:

答案 0 :(得分:0)

index.php和index.html页面是否存在于同一文档根目录中?

如果存在apache优先使用index.html而不是index.php。

请删除index.html。它会解决你的问题。

您使用的是.htaccess吗?详细说明。

如果是,请使用以下代码

Options +FollowSymLinks
DirectoryIndex index.php

RewriteEngine on

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
RewriteRule ^(.*)index\.html$ /$1index.php [R=301,L]