Odd .htaccess Problem

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
supermike
Forum Contributor
Posts: 193
Joined: Tue Feb 28, 2006 8:30 pm
Location: Somewhere in the Desert, USA

Odd .htaccess Problem

Post by supermike »

I have a site with some html files on it. One of them is contact.html. This is my .htaccess, and I'm having problems where I can address the page with http://site.com/contact, but not http://site.com/contact/. (Note ending slash.) What's the fix?

Code: Select all

RewriteEngine On
 
# If the requested URI does not contain a period in the final path-part
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
# and if it does not exist as a directory
RewriteCond %{REQUEST_fileNAME} !-d
# and if it does not exist as a file
RewriteCond %{REQUEST_fileNAME} !-f
# then add .html to get the actual filename
rewriterule (.*) /$1.html [L]
 
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Odd .htaccess Problem

Post by Christopher »

Try some thing like this:

Code: Select all

RewriteEngine on
RewriteCond %{REQUEST_FILENAME}     !-d
RewriteCond %{REQUEST_FILENAME}     !-f
RewriteRule !\.[a-zA-Z0-9]{2,4}$ /$1.html [L]
(#10850)
Post Reply