Web Hosting Talk







View Full Version : index.html over index.php priority?


jethbrown
06-30-2006, 07:51 PM
I have a client who has a cms in the root of his public_html directory, and you get to it with the index.php file.

Now he wants when you go to his http://yourdomain.com/ to automatically load a index.html file first, but it always goes to the index.php file instead.

Is there something I can either put in his .htaccess file or on his account to force the .html file to come up rather then the .php file. Basically the html needs to take priority over the php. He has a link on the .html file to go to the .php file. Moving the cms is a option, but he doesn't want this.

I just want it on this clients account, not server wide.

Cpanel/WHM, latest stable build is on the server.

brendandonhu
06-30-2006, 07:55 PM
This should do it
DirectoryIndex index.html index.php

jethbrown
06-30-2006, 08:51 PM
thanks, that fixed it.

brendandonhu
06-30-2006, 08:52 PM
You're welcome

BluFX
06-30-2006, 11:16 PM
i think there's a place to control this in cpanel as well.
call the file home.html or something, and set the / folder's index as home.html.

not sure though, ive only done it once, and that was a long time ago.

marcnyc
11-06-2009, 05:54 PM
I know it's an ancient post but I have the same issue. I followed brendandonhu's advice and added:

DirectoryIndex index.html index.php

to the .htaccess in the root of my server, but what I don't get is that even if I actually type: www.mydomain.com/index.php it will still go to index.html

Is there a way to make it go to the html file if you type mydomain.com but to make it go to the php if you type mydomain.com/index.php ???

Thanks

Website themes
11-07-2009, 01:12 AM
I know it's an ancient post but I have the same issue. I followed brendandonhu's advice and added:

DirectoryIndex index.html index.php

to the .htaccess in the root of my server, but what I don't get is that even if I actually type: www.mydomain.com/index.php (http://www.mydomain.com/index.php) it will still go to index.html

Is there a way to make it go to the html file if you type mydomain.com but to make it go to the php if you type mydomain.com/index.php ???

Thanks

This is what I suspect is happening. When you go to example.com/index.php the index.php script is redirecting the user to example.com/. When the browser requests example.com/ apache is serving index.html exactly as you have specified in the .htaccess file. So the problem is with the code in index.php and not related to apache.

Now you might ask why is the CMS redirecting example.com/index.php to example.com? Although I don't know what CMS your using I suspect it is an attempt to prevent duplicate content and is related to Search Engine Optimisation.

marcnyc
11-07-2009, 01:51 AM
I see... makes sense... I am using WordPress

Website themes
11-07-2009, 04:25 PM
I see... makes sense... I am using WordPress

Try disabling any plugins related to SEO. You could also use a firefox extension like livehttp headers to confirm that index.php is indeed redirecting visitors. Alternatively you could just post the URL of your site here and I'll take a look.

marcnyc
11-08-2009, 01:10 AM
the site is under re-design right now but you can see the problem at www.marcurselli.com, where you always see index.html, no matter what

Benny Kusman
06-18-2011, 02:00 PM
hi,

i know this is on old post.

i put DirectoryIndex but it does not work.
any idea ?

Website themes
06-18-2011, 02:35 PM
What is the address of your site?