• H2GD Part 39: How to deal with index.htm not found with WordPress subdirectory install?

    H2GD Part 39: How to deal with index.htm not found with WordPress subdirectory install?

    This post documents the solution we used to overcome a problem where attempts to visit a site using just the domain name ended up with a 404 error for index.htm. But is it the right solution?


    For some time now we’ve been developing a WordPress site in a subdirectory installation with the original, HTML only site, accessed through index.htm and other .htm files.

    When you visited the site at http://example.com then the page displayed was http://example.com/index.htm.

    The WordPress install was in a folder called wp. To view the WordPress site it was accessed as http://example.com/wp.

    Switching WordPress to become the live site

    By renaming index.htm to old_index.htm and following the Giving WordPress Its Own Directory instructions, we’ve now made the WordPress site live.

    But each visit to the domain name ( http://example.com ) still ended up with a request to http://example.com/index.htm, which resulted in a 404 error message.


    • Who’s asking for index.htm?
    • What can we do about it?

    Who’s asking for index.htm

    The access logs appear to show that the requests are coming in to the Apache server for index.htm. I’ve tried clearing caches and using different browsers to no avail. I suspect that my ISP have a proxy that is performing the URL change for me.

    What can we do about it?

    • Attempting to write a 301 redirect from index.htm to index.php or /wp/index.php creates a loop.
    • It is possible to write a 301 redirect to a different URL ( e.g. http://example.com/about-us ) but that still prevented us from actually accessing the Front page that was defined in Settings > Reading .

    Current solution

    • Create a new Front page by cloning the original Front page. Note: Expected permalink home-2
    • Choose this page for the Front page.
    • Write a 302 redirect for requests to index.htm to go to the original Front page
      RewriteCond %{HTTP_HOST} ^.*$
      RewriteRule ^index\.htm$ "http\:\/\/example\.com\/home" [R=301,L]

    This now appears to work.

    If I visit http://example.com I get shown the required Front page: http://example.com/home

    If I visit http://example.com/? I get shown the new Front page: http://example.com/?

    Firefox log

    Follow the 4 screen captures of the Network log from Firefox.

    1. Get / – 301 Moved Permanently
    2. Get index.htm – 302 Found
    3. Get home – 301 Moved Permanently
    4. Get home/ – 200 OK

    Further questions

    • Should I have used a 302 or 301 redirect?
    • How will I know when it’s safe to remove the redirect?
    • Could I have done this a better way?

    Postscript 11th April 2014

    There was a simple explanation after all.

    • Many moons ago we’d installed the redirection plugin
    • And set up an entry in the Redirections group for Source URL: / going to Target URL: index.htm
    • It was still active.
    • As soon as I removed this 301 redirect the problem was resolved
    • So I was able to delete 302 redirect from the .htaccess file

    The Problem Determination went very wrong because I’d forgotten all about this and guessed that something was happening when it really wasn’t.

    I should have spent more time attempting to reduce the problem to its simplest.

    I should have followed my own check list… Top 10 questions to ask when something doesn’t work

    DOH! I’ve now added this post into the “Probably Doing It Wrong” (PDIW) category.

    , ,


    Last updated:

    August 18, 2014

Today’s word is this:







Tide times from tidetimes.org.uk

Tide Times & Heights for Langstone Harbour on
19th June 2024
03:24 Low Tide ( 1.69m )
10:37 High Tide ( 4.22m )
15:43 Low Tide ( 1.68m )
22:54 High Tide ( 4.48m )

Tide times from tidetimes.org.uk

Tide Times & Heights for Northney on
19th June 2024
03:36 Low Tide ( 1.39m )
10:40 High Tide ( 3.91m )
15:40 Low Tide ( 1.45m )
22:54 High Tide ( 4.16m )