Here is my current .htaccess code
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
it is works only in removing .php extension
from
http://localhost/mysite/news.php?category=cat1&id=1
to
http://localhost/mysite/news/cat1/1/
and from
http://localhost/mysite/news.php?category=cat1&year=2011&month=10&day=25&id=1
to
http://localhost/mysite/news/2011/10/25/1
How to write complete .htaccess for the clean url above?
Try This
RewriteRule ^(.*)\/$ $1.php [NC]
for example
Add an optional / to your pattern:
You could just try a simple
RewriteRule
:This tacks on
.php
to any file-looking url:example.com/somethin
becomesexample.com/somethin.php
,example.com/something/else/
becomesexample.com/somethin/else.php
, etc.The only problem with this is if you try to access an actual folder, like
example.com/images
or something.