Results 1 to 6 of 6
  1. #1
    ABW Ambassador
    Join Date
    January 18th, 2005
    Location
    Singapore
    Posts
    1,597
    Need help with .htaccess
    Hi,

    I reworked a website, switching to wordpress and am trying to use .htaccess to redirect missing pages that ended with .htm or .html
    eg. widget.htm
    to http://www.mydomain.com?s=widget

    I put this in .htaccess

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.+).htm?$ http://www.mydomain.com?s=$1

    Can't seem to get it to work.

    Need your advice. How should I go about doing this?

    Thanks

  2. #2
    ABW Ambassador 2busy's Avatar
    Join Date
    January 17th, 2005
    Location
    Tropical Mountaintop
    Posts
    5,636
    RewriteRule ^([a-z]+).htm?$ might be what's needed? I don't have my files on this computer or I would be more certain. There is a helpful post here for rewrites in general: http://www.abestweb.com/forums/showp...61&postcount=9

  3. #3
    ...and a Pirate's heart. Convergence's Avatar
    Join Date
    June 24th, 2005
    Posts
    6,918
    Try this:

    Code:
    Options All -Indexes
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.+).htm?$ http://www.mydomain.com?s=$1  [R=301,L]
    All I did was add:

    Options All -Indexes to first line of the .htaccess file and added [R=301,L] to the end.
    Last edited by Convergence; February 17th, 2011 at 01:02 PM.
    Salty kisses, Sandy toes, and a Pirate's heart...

  4. #4
    ...and a Pirate's heart. Convergence's Avatar
    Join Date
    June 24th, 2005
    Posts
    6,918
    Better yet...

    Options All -Indexes
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.+)\.s?html?$ http://www.mydomain.com?s=$1 [R=301,L]
    This will redirect any file ending in .htm, .shtm, .html or .shtml ...
    Salty kisses, Sandy toes, and a Pirate's heart...

  5. #5
    ABW Ambassador
    Join Date
    January 18th, 2005
    Location
    Singapore
    Posts
    1,597
    Thanks!

    Convergence,

    I put
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.+)\.s?html?$ http://www.mydomain.com?s=$1 [R=301,L]

    right at the top of the .htaccess file, before the wordpress codes and it works. Thanks for the code and tip.

  6. #6
    ...and a Pirate's heart. Convergence's Avatar
    Join Date
    June 24th, 2005
    Posts
    6,918
    You're most welcome...
    Salty kisses, Sandy toes, and a Pirate's heart...

  7. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. htaccess help
    By John Kruger in forum Programming / Datafeeds / Tools
    Replies: 13
    Last Post: February 8th, 2008, 10:20 AM
  2. .htaccess maybe?
    By Kevin in forum Programming / Datafeeds / Tools
    Replies: 2
    Last Post: December 5th, 2006, 10:09 AM
  3. Getting rid of htaccess
    By BrattyKitty in forum Programming / Datafeeds / Tools
    Replies: 8
    Last Post: December 24th, 2004, 04:57 PM

Posting Permissions

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