views:

550

answers:

2

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 site.com/contact, but not site.com/contact/. (Note ending slash.) What's the fix?

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]
A: 

Instead of:

rewriterule (.*) /$1.html [L]

Try:

RewriteRule ^([^/]*)/?$ /$1.html [L]
Sean Bright
That fixed it. I just had to make certain to look for all relative pathing with src, href, and image links and switch them to fixed pathing.
A: 

Hi ,

Actually I am facing same above problem. I only want to run

~name/how instead of ~name/how.php

I have made following changes in .htaccess

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.php [L]

but it will run as

~name/~name/how

and at every link click it will added ~name in url.

Can you tell me what is wrong in .htaccess??