Page 1 of 1

Help needed on .htaccess rewrite rule to add a trailing slas

Posted: Mon Feb 11, 2008 5:53 am
by ans7540
Hi guys,

Can anybody help me on .htaccess rewrite rule to add a trailing slash

Currently links on my server are in below format

http://www.domainname.com/filename.html

I want to allow user to check this page with url
http://www.domainname.com/filename

Please help.

Thanks in advance.

Re: Help needed on .htaccess rewrite rule to add a trailing slas

Posted: Mon Feb 18, 2008 12:04 am
by Riquez

Code: Select all

Options +FollowSymLinks -Multiviews -Indexes
RewriteEngine on
RewriteBase /websites/test/website
 
RewriteRule ^([a-z]+)/?$ $1.html
Note: The above will only allow for you to use a-z in the filename, not numbers or other chars.
To allow numbers as well use

Code: Select all

RewriteRule ^([a-z0-9]+)/?$ $1.html
the /? part makes the trailing slash optional

This page is the ultimate resource for .htaccess help
http://perishablepress.com/press/2006/0 ... ss-tricks/