繁体   English   中英

输入index.php时,服务器或域默认恢复为index.html

[英]server or domain defaulting back to index.html when index.php is entered

像其他人一样,我希望能够在站点上同时运行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

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

我猜测您仍然可以通过在.htaccess中使用正确的顺序来保留index.phpindex.html (考虑到我提到的重定向):

DirectoryIndex index.php index.html

然后您将拥有:

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

暂无
暂无

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

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