输入index.php时,服务器或域默认返回index.html

Like others I want to be able to run both index.html and index.php on a site. I want the default site.com to go to site.com/index.html and when typed into the address bar "site.com/index.php" I want this to go to "site.com/index.php" . I have the same setup on another Wordpress site that works fine but I can't replicate it on a new one.

It will default to "site.com/index.html" stripping out the "index.html" in the address bar, but if I type site.com/index.php in the address bar it reverts to site.com . It strips off the '/index.php' at the same time. Here is my htaccess file. Anything obvious? thanks~

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

The way WordPress works is that it tries to prevent duplicate URLs, thus, when you go to example.com/index.php it will (301) redirect you to example.com/.

I gues you could still have index.php and index.html by using the right order in your .htaccess (taking into consideration te redirect I mentioned):

DirectoryIndex index.php index.html

Then you will have:

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