Results 1 to 7 of 7
  1. #1

    How to redirect *.html to *.htm via htaccess?

    How can I redirect html page inquiries to display htm pages? Google has the old html pages. but the new site is all htm.

    I tried a 301 htaccess redirect using:

    redirect 301 /*.htm /*.htm
    and
    redirect 301 /*.htm http://you.com/*.htm

    without success. Both crash the site. Other than keying in all new page names, how do I proceed?
    -----------------------------------
    AmeriWeb Hosting
    One Stop Business Solutions
    AmeriWeb Hosting

  2. #2
    OK, I just found the solution, after searching for over an hour. The format is:

    RedirectMatch 301 (.*)\.html$ http://www.example.com$1.htm

    Thanks to anyone who read this and was going to help out.
    -----------------------------------
    AmeriWeb Hosting
    One Stop Business Solutions
    AmeriWeb Hosting

  3. #3
    Join Date
    Jun 2009
    Location
    Kochi,India
    Posts
    177
    Try this

    RewriteEngine on

    RewriteCond %{HTTP_HOST} ^yourdomain.com$ [OR]
    RewriteCond %{HTTP_HOST} ^yourdomain.com$
    RewriteRule ^index\.html$ "http\:\/\/your\domain\.com\/index\.htm" [R=301,L]
    Ezeelogin -
    The ultimate multiple server administration software.
    *Parallel shell *rm -rf protection *SSH logging*automated password changes*encrypted storage*
    AdMod.com -Delivering innovative web hosting solutions

  4. #4
    Join Date
    Mar 2007
    Location
    Phoenix, AZ, United State
    Posts
    1,492
    Quote Originally Posted by Rekhatitus View Post
    Try this

    RewriteEngine on

    RewriteCond %{HTTP_HOST} ^yourdomain.com$ [OR]
    RewriteCond %{HTTP_HOST} ^yourdomain.com$
    RewriteRule ^index\.html$ "http\:\/\/your\domain\.com\/index\.htm" [R=301,L]
    You don't need to escape the right hand side of your rule.

    http://yourdomain.com/index.htm is fine

    As far as the first issue of redirecting .html to .htm, just do

    RewriteRule ^(.+)\.html$ $1.htm [L]

  5. #5
    Thanks to both Rekhatitus and HostSentry, your code works better. The original I had using only one line (RedirectMatch 301 (.*)\.html$ http://www.example.com$1.htm) caused issues when no page was requested (ie http://domain.com). Your way eliminated that issue.
    Last edited by robertk1; 07-23-2009 at 08:15 AM. Reason: better description
    -----------------------------------
    AmeriWeb Hosting
    One Stop Business Solutions
    AmeriWeb Hosting

  6. #6
    Join Date
    Mar 2007
    Location
    Phoenix, AZ, United State
    Posts
    1,492
    Quote Originally Posted by robertk1 View Post
    Thanks to both Rekhatitus and HostSentry, your code works better. The original I had using only one line (RedirectMatch 301 (.*)\.html$ http://www.example.com$1.htm) caused issues when no page was requested (ie http://domain.com). Your way eliminated that issue.
    Your way would have worked if it was http://www.example.com/$1.htm

  7. #7
    Great advice - thanks for this. I have changed my site to a .co.uk domain and have had to redirect to a com - this has saved me alot of time

Similar Threads

  1. Redirect old url to new url using .htaccess
    By mickscool in forum Hosting Security and Technology
    Replies: 3
    Last Post: 06-06-2009, 07:47 PM
  2. hmm I can't get my htaccess to redirect
    By lexington in forum Programming Discussion
    Replies: 6
    Last Post: 10-05-2007, 11:14 PM
  3. Help with 301 Redirect in .htaccess plz ?
    By Joel Theodore in forum Hosting Security and Technology
    Replies: 3
    Last Post: 02-27-2007, 06:53 PM
  4. .htaccess redirect
    By MarkerMart in forum Programming Discussion
    Replies: 5
    Last Post: 03-04-2005, 05:21 AM
  5. htaccess redirect
    By adnbmusic in forum Hosting Security and Technology
    Replies: 3
    Last Post: 05-20-2004, 11:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •