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 McCorklein category Technical Stuff