In Apache’s .htaccess you can set this in your .htaccess file:
DirectoryIndex index.php index.html index.htm
Here index.php comes up first, if not there then index.html, and after that index.htm.
Not sure if this will work with Nginx. I ran it through a converter and this came up:
index index.php index.html index.htm;
@fredlim
Just add one-line in server {..}
block:
index index.php;
After that reload nginx config. That should do the magic.
Thanks all and appreciate for your help.
I checked my Nginx config, it is same as your solution. I wrongly stated my problem.
I would like to visit my old site if I type:
http://www.example.com or http://www.example.com/index.html
but visit the new WordPress site:
http://www.example.com/index.php
However if I set the pritoirty to
index index.html index.htm index.php
then the WordPress site never show even I explicit type
http://www.example.com/index.php
It will always go to the old site.
🙁
Try changing:
index index.html index.htm index.php
to
index index.html
Finally I use a workaround to achieve the result.
I create a html template with a redirect link in <header>, in WordPress create an empty page and use that html template, then set the Setting->Reading->Front page to that empty page, which will redirect to my index.html
Cheers
I test the method again as suggested:
Changing
index index.html index.htm index.php
to
index index.hhtml
does not work. But I was enabled the multisite after I deployed the redirect index.html method, so not sure the above method not working is cause by multisite or not.
I don’t think multisite will create any problem.
Actually, I ran a simple test and found that, order of parameters matter most in line:
index index.html index.htm index.php
when both index.html and index.php exists.
I ran a test where I created a simple index.php and index.html files.
As expected index.php and index.html were accessible when I gave exact URL like example.com/index.php and example.com/index.html respectively.
For example.com/ – argument order in above line prevailed.
When I had index index.html index.htm index.php
– example.com/ used index.html
When I had index index.php index.html index.htm
– example.com/ used index.php
When I had index index.html index.htm index.php – example.com/ used index.html
Yes that’s what I got initially, but then I cannot get to the index.php WordPress site in that setting. Any idea?
If you are using wordpress on example.com AND index is set to index.php
then WordPress will create internal redirect for example.com/index.php to example.com/
If you test with a simple demo, then example.com/index.php and example.com/ – both will work