Hi guys,
In this tutorial, i will let you know how to remove files extensions like .php, .html, .htm etc using htaccess file in php. So here i will write code of RewriteRule and it will remove file extensions from URL.
As we know, if you are working on core php project or simple html pages and upload it to server. it will work like as bellow link:
https://hdtuto.com/cat/laravelexample.html
https://hdtuto.com/cat/laravelexample.php
As you can see both way you can access your page as you created using html or php. But you can remove .html and .php from url using htaccess like you can make url like this way:
https://hdtuto.com/cat/laravelexample
So now as bellow you can learn how to remove .html and .php from url so let's see bellow solution:
Remove .php Extensions: .htaccess
RewriteEngine On
RewriteCond % !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
Remove .html Extensions: .htaccess
RewriteEngine On
RewriteCond % !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
Remove .htm Extensions: .htaccess
RewriteEngine On
RewriteCond % !-f
RewriteRule ^([^\.]+)$ $1.htm [NC,L]
For GoDaddy Users: .htaccess
Options +MultiViews
RewriteEngine On
RewriteCond % !-d
RewriteCond % !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
I hope it can help you....
Do you like below Tutorials ?
- Angular 9 HttpClient Request with RxJS Observable Example
- How to Create Routing Module in Angular 9?
- How to Create Custom Directive in Angular 9?
- Print Iframe Content using JQuery Example
- Allow Only Numeric Values in Textbox using JQuery
- Codeigniter Confirmation Box Before Delete Item Example
- How to Use Sweet Alert in Codeigniter?
- Disable F5 Key And Browser Refresh Using Javascript