Forum Moderators: phranque

Message Too Old, No Replies

How to write mod rewrite to hide particular folder url? (htaccess)

folder hide mode_rewrite htaccess

         

boyfromdaheaven

3:01 pm on Oct 12, 2009 (gmt 0)

10+ Year Member



Anyone can help me to change this url:

http://example.com/clt/demobasic/index.html

to

http://example.com/demobasic

using mod_rewrite? i want the "clt folder" hidden in url n so do "index.html" so that url entered is
http://example.com/demobasic which the file actually in
http://example.com/clt/demobasic/index.html

Helps much appreciated

[edited by: jdMorgan at 3:35 pm (utc) on Oct. 12, 2009]
[edit reason] example.com [/edit]

jdMorgan

3:50 pm on Oct 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi boyfromheaven, and welcome to WebmasterWorld!

You cannot change the URL that shows in the browser address bar using Apache mod_rewrite or mod_alias without causing other problems.

What you can do is to change the link on your page (in the HTML <a href="xyz"> tag) to "http://example.com/demobasic", and then use an internal rewrite in mod_rewrite to 'connect' that URL with the file "/clt/demobasic/index.html". Both of these steps are required in order to do what you want.

An optional third step is to detect direct client requests for "http://example.com/clt/demobasic/index.html" and redirect them to "http://example.com/demobasic". However, this step can only be done once the other two steps have been taken and have been tested.

Specific questions are welcome and we are happy to help, but we don't have enough volunteers here to write your code for you. Also, because using code on your server that you do not understand can be dangerous to your site's proper operation and search rankings, we are here to "teach you to fish" instead of just "giving you one fish."

Please review our Apache Forum Charter [webmasterworld.com] and visit the pages cited as resources. You may also wish to look through the threads in our Apache Forum Library [webmasterworld.com]. Then post your best effort at coding a solution as a basis for discussion.

Thanks,
Jim