WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Redirect from index.html to index.php (4 posts)

  1. sueme
    Member
    Posted 4 years ago #

    I've recently changed a site to WordPress 3 from Drupal, and I've managed to keep all the existing links working with one notable exception.

    I've got quite a few incoming links to index.html (which now doesn't exist).

    Is there a way of redirecting from index.html to (I assume) index.php?

    I'm using WordPress3 with the TwentyTen Theme and Permalinks. I'm also using the All in One SEO Pack plugin.

    Can anyone please help, or point me in the right direction.

  2. sueme
    Member
    Posted 4 years ago #

    More info:

    My existing .htaccess reads as follows:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    I did a Google search, and it looks as though I may be able to add the following to the .htaccess:

    Options +FollowSymLinks
    RewriteCond %{THE_REQUEST} ^.*/index.html
    RewriteRule ^(.*)index.html$ http://www.yoursite.com/$1 [R=301,L]

    However, I'm not fully sure how to do this and don't want to screw things up.

    Where exactly do I add the second bit of code to the first bit?

    Can anyone tell me please?

  3. sueme
    Member
    Posted 4 years ago #

    OK Sorted.

    Putting the new code under the existing code doesn't appear to work, but putting the new code at the top does work.

    Presumably it diverts index.html to index.php first, then activates the rest of the code.

    The full code that works is:

    RewriteCond %{THE_REQUEST} ^.*/index.html
    RewriteRule ^(.*)index.html$ http://mysite.com/$1 [R=301,L]
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
  4. Chris Brennan
    Member
    Posted 3 years ago #

    Thanks a lot for posting this. I was having the same problem and this did the trick.

Topic Closed

This topic has been closed to new replies.

About this Topic