Convoluted Brian

the weBlog of Brian McCorkle

The Importance of Understanding

Redirect index.html to index.php Tip

When I changed my blogging software from iBlog to WordPress, the required index changed from index.html to index.php. So users who tried to access www.convolutedbrian.com/index.html were greeted with a not found page.

Using an Apache Server, It would seem to be a trivial exercise to modify the htaccess file to redirect the html index to the server root and then pick up the php index. Not so as it turned out.

If I redirected index.html to index.php there were side effects. I have set up WordPress so all my posts appear as convolutedbrian.com/bigdealpost.html. So every post appears as an html address in the root directory (I’m not sure how wise this is). Some people were getting a double html so bigdealpost.html would come out as bigdealpost.htmlhtml. The result was the dreaded not found error. This didn’t happen to me, but I was picking this up in the error logs.

If I tried to redirect /index.html to ‘/’ big time misery was the result. The server would go into a loop because ‘/’ was index.html. Finally, the aha set in and the fix was simple.

In the htaccess for my blog, I inserted “DirectoryIndex index.php index.html.” Then I added “Redirect permanent /index.html http://dev.convolutedbrian/” to the htaccess file, and the redirect worked as expected and desired.

The usual order for DirectoryIndex has index.html first. Redirecting index.html to / tries to pick up index.html and the redirect kicked in again – and again.

Now everything is the way I want it to be There is another benefit. I have a “under maintenance” page that is pure html. I can name this to index.html and then when I am changing things on my blog, I just rename the index.php to something like index.phpm and index.html will automatically take over.

by Brian McCorkle
posted on 30 May, 2006 at 12:01 pm
in category Technical Stuff

I noticed that some people were trying to access my blog with index.html which generated an error since there was no index.html, only index.php. A simple redirect of index.html to / caused grief. And, I preferred not to redirect to index.php. In retrospect the solution was simple.



if you enjoy this blog, consider adding something to the tip jar for
Convoluted Brian

Secure Payment Accepted


Use PayPal with or without an account

Convoluted Brian Home


Categories:



Archives


Syndicate this Site




Visit

Brian the Brain
my Photography web site

brian the brain prints
fine art canvas prints from Brian the Brain

Brian the Writer
more essays plus poetry and short stories