Forum Moderators: phranque

Message Too Old, No Replies

blanket extension redirect

htaccess help needed

         

tom440

1:04 pm on May 26, 2007 (gmt 0)

10+ Year Member



I want to change all the extensions on one of my sites so that I can separate it out of the access log. My new hosting service puts all 5 in the same access log.
What I want to do is have a simple line that changes x.htm, y.htm, and z.htm to x.html, y.html, and z.html without having to write 1000 individual redirects.
Questions:
What is the term for this type of redirect
where do I go to find the code.

jdMorgan

5:04 pm on May 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In order to get this right, we need to know which is the requested (on-page) URL and which is the actually-existing filetype. Otherwise, we can't even give a good example to get you started.

The distinction between URLs and filepaths is critical to understanding URL rewriting and/or redirection.

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

tom440

1:41 am on May 27, 2007 (gmt 0)

10+ Year Member



the files all have this format
http://example.com/car.htm
and want to change it to
http://example.com/car.html

http://example.com/bus.htm
and want to change it to
http://example.com/bus.html

I have about a 1000 different pages. I want to retain each pages original name and just change the extension. I am not redirecting a page to a different page. Does this help?

jdMorgan

1:53 am on May 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Assuming that you are changing your on-page links from "htm" to "html" while the files will remain named ".htm", then an example to rewrite all of them would be:

RewriteRule ^{.*}\.html$ /$1.htm [L]

This rewrites client requests for URLs ending with ".html" to corresponding files ending with ".htm" -- Again, the distinction between a URL-path and a filename is critical, because having been rewritten, they are no longer the same.

Jim

tom440

6:11 pm on May 27, 2007 (gmt 0)

10+ Year Member



Thank you. That is more than I hoped for. I can edit this to make it work. To be sure this is understood what I am doing as I am sure it is a littlt unusual. When I rename a file from bus.htm to bus.html I will update all the links between pages. I was only looking for a way that people finding a page in a search engine or all the users that have bookmarks can come to the site without getting a 404.

g1smd

11:42 pm on May 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Serving each page under two filenames, both returning "200 OK" status, is Duplicate Content and should be avoided. One URL of the pair should issue a 301 redirect to avoid that happening.

tom440

3:01 am on May 28, 2007 (gmt 0)

10+ Year Member



I plan to delete all the *.htm files