url rewriting with .htaccess

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kalpesh
Forum Commoner
Posts: 54
Joined: Sun Sep 21, 2008 5:04 am

url rewriting with .htaccess

Post by kalpesh »

:banghead: hi, i am trying to rewrite url with .htaccess
This is my .htaccess file in root directory.
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php [nc]

Mod_rewrite is also enabled in apache.
It shows in phpinfo page.In apache2handler,under section of loaded modules he
is showing mod_rewrite but..

when i try to run index.php file from browser as index.html it shows the error as
index.html is not found on server.
I try to run in localhost.
Please help me. :banghead: :banghead: :banghead:
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: url rewriting with .htaccess

Post by onion2k »

Make it redirect so you can see what it's doing eg:

RewriteRule ^(.*)\.html$ $1.php [R,NC]

You may need to define a condition too.. Put this before the rule line:

RewriteCond %{QUERY_STRING} ^(.*)$
Post Reply