Hide .php file extension from url using .htaccess


1. Paste this code in .htaccess file and change “yoursiteaddress” to your website address

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursiteaddress.com$
RewriteRule ^(.*)$ "http\:\/\/www\.yoursiteaddress\.com\/$1" [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
Advertisements

One thought on “Hide .php file extension from url using .htaccess

  1. Thanks for one’s marvelous posting! I seriously enjoyed reading
    it, yoou can be a great author.I will be sure to bookmark your
    blog and definitely wkll come back sometime soon.I want
    to encouraqge you to definitely continue your greaat posts, have a nicce evening!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s