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

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
ans7540
Forum Newbie
Posts: 1
Joined: Mon Feb 11, 2008 5:48 am

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

Post 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.
Riquez
Forum Newbie
Posts: 10
Joined: Sun Feb 17, 2008 6:39 pm

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

Post 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/
Post Reply