Some client doesn’t like to show their file extension on their website URL. They don’t want to display their website URL like,
domain.com/index.php
domain.com/blog/index.php
They need the URL’s like
domain.com/index
domain.com/blog/index
Some SEO suggests this setting for the website and I personally don’t know the reason behind that. In cPanel with the newer version of Apache installed, you can use the below htaccess rules to complete the redirection.
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*[^.#?\ ]+\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*[^.]+)\.php http://www.domain.com/$1 [R=301,L]
On the above code;
FollowSymLinks:- Tells the web server to follow symbolic links while looking for a file.
MultiViews:- Search is where the server does an implicit filename pattern match, and choose from the results.
domain.com:- Replace it with your own domain name
When you place the above code on your domain’s root directory the site URL’s will become
domain.com/index.php -> domain.com/index (no extension)
domain.com/blog/folder/ -> domain.com/blog/folder (No trailing slash)
Note: The above code will also replace the trailing slash of your website to none? like with the above code your website URL will not display trailing slash at the end of it.
Hope someone will find this blog useful (If their SEO requests this 🙂 )
” margin_top=”50px” margin_bottom=”” animation_type=”slide” animation_direction=”left” animation_speed=”0.3″ class=”” id=””]
Leave A Comment
You must be logged in to post a comment.