PDA

View Full Version : htaccess mod rewrite



vineet
12-14-2008, 11:02 AM
hi

i have my all urls ending with .php


http://localhost/vineet/index.php


i have removed the extension with htacess


http://localhost/vineet/index/


this is htaccess


Options +FollowSymlinks
RewriteEngine On
RewriteRule ^(.+)/$ $1.php


now if anyone writes index.php or contactus.php . means if anyone adds the .php extension to my url then i want to show him an error page or page not found page or redirect to index page.

but my pages should not get effected.

vineet

maneetpuri
12-15-2008, 12:06 PM
Hi,

Below is the code you can put in your .htaccess to do this

RewriteEngine On

RewriteCond %{HTTP_HOST} ^domainname\.com\\*.php

RewriteRule ^(.*)$ http://www.domianname.com/ /* use it if you want to redirect to home page */

RewriteRule ^(.*)$ http://www.domianname.com/errorpage/ /* use it if you want to redirect to error page */

Hope this works for you!

Cheers,

~Maneet
Lexolution IT Services
Web site Development Company (http://www.lexolutionit.com/)