View Full Version : No File Extensions on URLs

Joseph Witchard
04-08-2010, 05:32 AM
How do you remove them? I remove them with the following code (using mod_rewrite):

^(somepage|someotherpage)/?$ /$1\.php

But, I've heard there's a more efficient way to do it. What is it?

04-09-2010, 04:04 PM
you method looks ok to me,

but there are a few ways to do this;

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Joseph Witchard
04-12-2010, 06:47 AM
Would you mind explaining each line to me? I don't mean to be an annoyance, but I've only ever done a couple of things on .htaccess, so it's still very new to me.