WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] What is the proper 301 redirect for this situation? (9 posts)

  1. JC10002
    Member
    Posted 2 years ago #

    Hello,

    I have a website that I recently revamped using WordPress.

    Can someone please provide me the .htaccess code I can use to achieve the following:

    I want to 301 redirect all current pages that end in .html to my home page.

    So, for example, http://www.my-example-site/aboutme.html will redirect to my home page. But http://www.my-example-site/services/ will not redirect anywhere.

    I have many pages indexed in Google with .html currently going to a 404 page.

    Thanks for your input on this one.

    -Josh

  2. esmi
    Forum Moderator
    Posted 2 years ago #

  3. JC10002
    Member
    Posted 2 years ago #

    Thanks Esmi for the link.

    If I'm reading things correctly, is this the code for me to use:

    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule ^(.+)\.html$ http://my-example-site.org/ [R=301,NC]

    Will that send all URLs that end in .html to the home page, while keeping all other URLs such as my-example-site/services/ intact?

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    I think so - although I have to admit that url rewriting always gives me a headache too. :-)

  5. Yes, that'll work :)

    I'd use ^(.+)\.htm? personally, but that's a functional redirect :)

  6. JC10002
    Member
    Posted 2 years ago #

    Hi Gang,

    Not sure why the code is not working, but it's not working :(

    I include it before the current WordPress code in my .htaccess file and I tried to include it after.

    When I then visit my-example-site.com/asdfrtyh.html it returns a typical WordPress 404 not found page - no forward occurs.

    What am I overlooking?

    Thanks again. -Josh

  7. It should be before, not after. And ... o.O

    Okay. Thats weird. Oh... Damned periods.

    RewriteRule ^(.*)html http://example.com [R=301,L]
  8. JC10002
    Member
    Posted 2 years ago #

    Hi Ipstenu,

    That did it. Thank you so much. I really appreciate that help.

    -Josh

  9. No problem!

Topic Closed

This topic has been closed to new replies.

About this Topic