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 🙂 )

[tagline_box backgroundcolor=”description=” shadow=”no” shadowopacity=”0.7″ border=”1px” bordercolor=”” highlightposition=”top” content_alignment=”left” link=”” linktarget=”_self” modal=”” button_size=”” button_shape=”” button_type=”” buttoncolor=”” button=”” title=”” description=”If you have any queries on how to display website URL without file extension feel free to leave us a message and our representative will get back to you.

” margin_top=”50px” margin_bottom=”” animation_type=”slide” animation_direction=”left” animation_speed=”0.3″ class=”” id=””]

[/tagline_box]