301 Redirect Problem: changing from .htm to .html

8 replies
  • WEB DESIGN
  • |
I have an old site that was built with Dreamweaver with .htm pages. I just rebuilt the entire site in XsitePro which creates .html pages. I set up 301 redirects in Xsite Pro for all pages, but I'm getting 401 errors on all of them. So I created an .htaccess file through my cPanel and configured all of the 301 redirects again, but still getting the 404 error.

I'm beginning to wonder if it is not possible to redirect from an old .htm page to a new .html page? Any ideas would be appreciated. Thanks.
#301 #changing #htm #html #problem #redirect
  • Profile picture of the author KirkMcD
    would you post an example of a redirect you are using?
    {{ DiscussionBoard.errors[3460841].message }}
    • Profile picture of the author barbdear
      Sure. They all look like this:

      Redirect 301 /product/pages/widget/blue.htm http//:www.gadgets.com/widget.html
      {{ DiscussionBoard.errors[3460937].message }}
      • Profile picture of the author David V
        Barbdear, this is an easy fix.
        open your .htaccess file and add:

        RewriteEngine On
        RewriteRule (.*).htm $1.html [PT,L]

        The WHY: The "$1" passes the entire URL back and only the extension is
        changed. Any query string from a dynamically generated page will
        be passed as well.
        {{ DiscussionBoard.errors[3463102].message }}
  • Profile picture of the author jminkler
    My next question has to be .. why not use a shopping cart or CMS ? That must be painful to update that many pages, no?
    {{ DiscussionBoard.errors[3463490].message }}
    • Profile picture of the author David V
      You don't have to update any pages. Use the htaccess code, it will change the extension for all pages.
      {{ DiscussionBoard.errors[3463694].message }}
      • Profile picture of the author barbdear
        Thanks, I tried the fix from David V, but I'm still getting the 404 error. It must be something unrelated to the .htm vs .html issue.

        I"m starting to think I'm stuck with it the way it is.
        {{ DiscussionBoard.errors[3466005].message }}
        • Profile picture of the author David V
          sorry you still having a problem! the htaccess is valid. This makes the assumption your hosting on linux not windows.
          When you add this snippet you can't have the other 301's in there at the same time.
          Try it with a clean htaccess. just back up the old one. You also don't need "RewriteEngine On" if it's already called at the top.
          {{ DiscussionBoard.errors[3466433].message }}
          • Profile picture of the author barbdear
            Thanks, David V for taking the time to help. I really appreciate it.

            I called Hostgator for some help, and they had me set up the 301 redirects through my CPanel. I didn't know that was possible, but it worked like a charm. Rebuilding this site certainly has been a learning experience!

            OK, back to work. It's time to build some new pages and grow this thing.
            {{ DiscussionBoard.errors[3466736].message }}

Trending Topics