WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] 301 Redirect ALL .htm Pages To .php Pages? (5 posts)

  1. Aedryan Methyus
    Member
    Posted 2 years ago #

    Howdy WP users!
    Well, I FINALLY just finished converting my website (about 500 pages!) over into WordPress and the site is now live! Talk about A LOT of work!

    Anyway... I need to setup a 301 redirect in my htaccess file, which directs all og my old .htm URLs to their new corresponding .php URLs. The page names haven't changed, just the extensions. I have tried a few different codes that i've found, but none of them seem to work.

    Here is what I tried for my last attempt:

    RewriteCond %{HTTP_HOST} ^domain.com
    RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
    
    RewriteRule ^(.+)\.htm$ http://www.domain.com/$1.php [R=301,L]

    Should the 301 redirects happen immediately or does it take awhile for the server to catch it or something?

    Any help or suggestions would be greatly appreciated! I'm afraid the spiders are going to come along and crawl some of my pages that were already .php and i'm going to end up getting penalized/banned for duplicate content or something...

    Thanks.

    ~ Aedryan

  2. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Try:

    RewriteRule ^(.*).htm /$1.php [R=301,L]

    (and this needs to be added outside and before the WordPress rules and call the rewrite module in use).

  3. Aedryan Methyus
    Member
    Posted 2 years ago #

    BINGO! That worked! It didn't at first, but I decided to try and delete my cookies and try again. That's all it took. I would imagine the other codes I tried would have worked too, if I had done that.

    Thanks for your help brother! >8>)

    ~ Aedryan

  4. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Please mark post as resolved as this will help others.

  5. Aedryan Methyus
    Member
    Posted 2 years ago #

    *****RESOLVED*****

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.