Removing file extensions using htaccess

Removing file extensions using htaccess

In this Post We Will Explain About is Removing file extensions using htaccess With Example and Demo.Welcome on – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to How to remove .php, .html, .htm extensions with .htaccess Example

Free Live Chat for Any Issue

In this post we will show you Best way to implement remove .php, .html, .htm extensions using .htaccess, hear for How to Remove php, html Extension from URL using htaccess with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

htaccess – How to remove .php, .html, .htm extensions with .htaccess

we are going to learn you how to step by step remove .php extensions, .html extensions and .htm extensions using .htaccess file.

Remove .php, .html, .htm Extensions

To remove the simple.php extension from a core PHP file as an example Like as a to we have got to feature the some subsequent code within the put .htaccess file

Read Also:  or condition in codeigniter - How to use multiple where condition in Codeigniter?

RewriteEngine On
RewriteCond % !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

If we would like to some get rid of the any extension like as a .html extension from a simple HTML file as an example like as a to we just ought to alter the last simple line from the source code higher than to simple last step match the computer new filename

RewriteRule ^([^\.]+)$ $1.html [NC,L]

we shall currently link simple root pages within the any HTML document without some having to data feature the new extension of the page.

For example:

<a href="" title="my-pages">NAME-OF-LINK</a>

Adding a trailing slash at the tip

We received several some htaccess requests asking a second way to put a trailing slash at the some tip. Ignore any data the primary piece and near add insert the subsequent source code.

Read Also:  How to (Easily) Change Date Format in codeigniter?

The primary four simple lines modify the removal some extension like as a .html .php as well as .htm of the extension and so the following, with the addition futures of the trailing slash related SEO and redirecting.

Link to the DOM HTML as well as PHP file as shown higher more than. Don’t forget to simple line alter the source code if we would like it changes applied to associate simple HTML file.

RewriteEngine On
RewriteCond % !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond % !-f
RewriteCond % !-d
RewriteCond % !(\.[a-zA-Z0-9]|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

Note For GoDaddy User

Attention For GoDaddy users onlytherefore as to simple get rid of the any extensions We wish to modify add some source code htaccess file to MultiViews before.

The code ought to appear as if this

Options +MultiViews
RewriteEngine On
RewriteCond % !-d
RewriteCond % !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

If We are disquieted that data search engines may some index these pages as any copy or duplicate data content, ne had tag w pu a canonical meta tag in your simple HTML head secotions

Read Also:  Pattern programs in GO Example

<link rel="canonical" href="">



I hope you have Got What is How to remove .php, .html, .htm extensions with .htaccess And how it works.I would Like to have FeadBack From My Blog( readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article( Are Most Always Welcome.