简体   繁体   English

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

[英]After changing extension html to php, page redirected

I have changed my file extension, HTML to PHP. 我将文件扩展名从HTML更改为PHP。 When I browse in localhost, it is redirected to main server. 当我在localhost中浏览时,它将重定向到主服务器。 I am using github and files are developed using HTML5boilerplate with twitter bootstrap. 我正在使用github,文件是使用带有twitter bootstrap的HTML5boilerplate开发的。 I have committed in github several with the extension HTML. 我已经在github中提交了几个扩展名为HTML的文件。 ie my previous url: [localhost]/sovolve.com/new/index.html current url: [localhost]/sovolve.com/new/index.php 即我以前的网址: [localhost]/sovolve.com/new/index.html当前网址: [localhost]/sovolve.com/new/index.php

when I browse in localhost with current URL it is redirected to http://sovolve.com/new/index.html 当我使用当前URL在localhost中浏览时,它将重定向到http://sovolve.com/new/index.html

Please let me know someone if codes need to be updated. 如果需要更新代码,请告诉我。

Is both index.php and index.html pages are present in same document root ?? 是否index.php和index.html页面都存在于同一文档根目录中?

If present apache gives priority to the index.html rather than index.php. 如果存在,则apache优先于index.html而不是index.php。

Please delete that index.html. 请删除该index.html。 It will fix your issue. 它将解决您的问题。

Are you using .htaccess. 您是否正在使用.htaccess。 Give in details. 详细说明。

If yes use below code 如果是,请使用以下代码

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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM