Jeffrey L. Roberts
Jeffrey L. Roberts

Reputation: 2984

Force trailing slash for a specific url with htaccess

I have been viewing the other posts on stackoverflow.com about forcing a trailing slash, however, I can not seem to find a post regarding forcing a trailing slash for one specific url, and the scenarios I have found break other parts of the site.

Here is my dilemma. I have the following URL

http://www.example.com/directory 

However, due to legacy code, and relative paths, the CSS is not showing when that URL is viewed. When a slash is added to the end, the CSS and everything else works great. So what I would like to do is force a trailing slash for that specific URL and no others.

Example of url to force trailing slash

http://www.example.com/directory

Example of above url with trailing slash

http://www.example.com/directory/

Example of another url that I do not want to force a trailing slash

http://www.example.com/directory/foo

Any ideas, thoughts, suggestions, or comments are greatly appreciated! Thank you!

Upvotes: 0

Views: 1050

Answers (1)

Luke
Luke

Reputation: 4063

You could use .htaccess to do this

RewriteEngine on

RewriteRule ^directory$ directory/

Upvotes: 1

Related Questions