how to remove .php from url using htaccess

Опубликовано: 07 Февраль 2026
на канале: TutorialShore
76
0

how to remove .php from url using htaccess , Here is the htaccess tutorial in php to remove dot extension from the URL


#first step to start rewrite
RewriteEngine On
this below line is whenever .php files are calling iit find out
it may be home.php about.php contact_us.php

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
#this is the rule to redirect if it is about.php it will redirect to about
RewriteRule ^/?(.*)\.php$ http://localhost/php/$1 [L,R=301]

this is the condition will redirect all about to about.html it is actually hidden redirect
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ /php/$1.php [NC,L]