【问题标题】:After changing extension html to php, page redirected将扩展 html 更改为 php 后,页面重定向
【发布时间】:2013-11-16 08:45:15
【问题描述】:

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

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

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

【问题讨论】:

    标签: php html html5boilerplate


    【解决方案1】:

    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]
    

    【讨论】:

    • 这是一个简单的html页面。我不使用 .htaccess。此外,没有两个文件,因为我将 html 文件的扩展名更改为 php。所以,只有 index.php
    • 感谢@Sanjog,实际上我的问题不是重定向某些东西。我的问题很简单,我在更改扩展名后运行了一个 html 文件,它重定向到某处(服务器)。这不在 .htaccess 问题中。也许在 GITHUB
    猜你喜欢
    • 2012-08-09
    • 1970-01-01
    • 1970-01-01
    • 2015-04-25
    • 2012-10-29
    • 1970-01-01
    • 1970-01-01
    • 2014-09-17
    • 1970-01-01
    相关资源
    最近更新 更多