Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite module

         

quozl

5:26 am on Jan 12, 2006 (gmt 0)



I am trying ever so hard in my .htaccess file to get my [......] page to read [......]

I also have 4 other pages in this directory that I want to be listed as /example/ instead of /example.html

I am new with Apache and rewrite so any help you can render will be GREATLY appreciated.

quozl

jdMorgan

1:19 pm on Jan 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



quozl,

Welcome to WebmasterWorld!

It appears that you may be going about this backwards.

If you want to change the 'displayed URL' then you must change the links on your pages.

Once a visitor (person or robot) follows those links, and requests the new URL from your server, you can use mod_rewrite to change the internal file that corresponds to that URL, or you can redirect to a different URL. However a redirect requires that the client (browser or robot) re-fetch the desired content from the new URL, and that is inefficient. So, the proper way to do this is to correct the links on your pages.

The process will then look like this:

Link on page <a href="/example/">Link text here</a>


mod_rewrite code:
RewriteRule ^example/$ /example.html [L]

You may also want to look into the DirectoryIndex [httpd.apache.org] directive of mod_dir if these are all "index" pages of your directories. If you can use DirectoryIndex, you may not need mod_rewrite at all to solve this problem.

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