【问题标题】:server or domain defaulting back to index.html when index.php is entered输入 index.php 时服务器或域默认返回 index.html
【发布时间】:2014-11-22 01:17:00
【问题描述】:

像其他人一样,我希望能够在网站上同时运行 index.html 和 index.php。我希望默认的 site.com 转到 site.com/index.html ,当输入地址栏 "site.com/index.php" 时,我希望它转到 "site.com/index.php" 。我在另一个 Wordpress 网站上也有同样的设置,但我无法在新的网站上复制它。

它将默认为“site.com/index.html”,去除地址栏中的“index.html”,但如果我在地址栏中键入site.com/index.php,它会恢复为site.com .它同时剥离了“/index.php”。这是我的 htaccess 文件。有什么明显的吗?谢谢~

DirectoryIndex index.html index.php

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . /index.php [L]

RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

</IfModule>

# END WordPress

【问题讨论】:

    标签: php wordpress .htaccess


    【解决方案1】:

    WordPress 的工作方式是尝试防止重复的 URL,因此,当您转到 example.com/index.php 时,它会 (301) 将您重定向到 example.com/

    我想你仍然可以通过在 .htaccess 中使用正确的顺序来拥有 index.phpindex.html(考虑到我提到的重定向):

    DirectoryIndex index.php index.html
    

    那么你将拥有:

    index.php ===> /
    index.html ==> /index.html
    

    【讨论】:

      猜你喜欢
      • 2011-07-31
      • 2014-02-18
      • 2013-11-03
      • 1970-01-01
      • 2012-04-17
      • 1970-01-01
      • 2011-05-26
      • 2011-07-11
      • 2013-11-22
      相关资源
      最近更新 更多