Forum Moderators: phranque

Message Too Old, No Replies

Is this possible?

Appending a / using .htaccess

         

Naif

12:03 pm on Dec 22, 2006 (gmt 0)

10+ Year Member



Hello everyone. I am new here :) I have a question regarding .htaccess. I dont know its syntax so I am not sure if this could be possible.

I was wondering if there is a way using which, if a person tries to access a site, say example.com without a slash at the end, could we make use of the htaccess file to append a slash at the end?

You guys might be wondering why I would want to do this. I have a genuine reason. I run a web directory which is powered by phpLD. It has something which I guess qualifies as a bug. I tried posting it on their forum for a fix but they havent given a fix yet. Let me demonstrate what the problem is and for this I'll have to use my site as an example. [If you tried] accessing this page:

http://www.example.com/computers_and_internet/web_directories

[You'd] see 8 subcategories. Lets take the subcat Paid Directories for example. If you accessed the page with the url I gave, you'd notice that the link to Paid Directories points to http://www.example.com/computers_and_internet/paid_directories/, which is WRONG!

It should point to, http://www.example.com/computers_and_internet/web_directories/paid_directories

If you were to access http://www.example.com/computers_and_internet/web_directories with a trailing slash, this problem wont happen. So I want to make sure, if a user doesn't put a slash at the end of the URL, apache automatically puts on there...

Please let me know if this is possible :)

Regards,
-- Naif

[edited by: jdMorgan at 3:09 pm (utc) on Dec. 22, 2006]
[edit reason] No URLs, please. See Terms of Service. [/edit]

jdMorgan

3:14 pm on Dec 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Naif,

Welcome to WebmasterWorld!

Have you tried a search [google.com] on this subject?

There are many examples of the code to do this already posted here. They should help get you started.

Jim