WordPress.org

Ready to get started?Download WordPress

Forums

WordPress 2.0: Adding Permanent Re-direct to .htaccess (4 posts)

  1. EcoGraphic
    Member
    Posted 7 years ago #

    I have been upgrading several old static websites lately to WordPress. In order to transfer the pagerank in Google over to the new website, you need to create permanent redirects for each of the old .html pages in the .htaccess file.

    After searching numerous websites for info on how to do this, I finally got this to work. Here is what your .htaccess file should look like after you have added in your permanent re-directs. You will need one re-diect for each old page.Each re-direct should be on one line only, not two, with a single space between the old page name and new location. Make sure you pay attention to the forward slashes: one before the old page name, and none at the end of the new page location.

    *Note: Remove the [] from the location of the new page shown below.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    Redirect permanent /old_page.htm [http://www.yoursite.com/new_page]
    Redirect permanent /old_page2.htm [http://www.yoursite.com/new_page2]
    </IfModule>

    # END WordPress

  2. Christopher J. Hradil
    Member
    Posted 7 years ago #

    there's actually an easier way to do this, just create WP "pages" named the same thing as the old pages but without the .html extension (old_page instead of old_page.html for example), then just create one re-write rule to append the .html to the address (you could also do this with posts/category structure and custom permalinks which end with .html, see the codex permalinks section for more details on this) we've used both methods, and both work pretty much the same, something like old_page.html becomes either a WP post called old_page or a WP page called old_page, then by adding the .html either through permalinks or .htaccess you retain the old pagerank since to google, etc, the same page is available via the old URI.

    this is a much better strategy than redirecting to new URI's which can have mixed results when it comes to page rank.

    ...c

  3. EcoGraphic
    Member
    Posted 7 years ago #

    You must also disable wp-cache while you add permanent redirects to the .htaccess file, or it will just revert back to the .htaccess file without the redirects once the cache expires

  4. EcoGraphic
    Member
    Posted 7 years ago #

    You also need to add this line before your permanent redirects:

    # redirect a page or directory

    so your .htaccess file would read:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # redirect a page or directory
    Redirect permanent /old_page.htm [http://www.yoursite.com/new_page]
    Redirect permanent /old_page2.htm [http://www.yoursite.com/new_page2]
    </IfModule>

    # END WordPress

Topic Closed

This topic has been closed to new replies.

About this Topic