Rushit
Rushit

Reputation: 526

How to remove .php or .html extension from single page?

I have a website eg : www.abcd.com in that there are many pages. eg : www.abcd.com/one.php , www.abcd.com/two.php I just want to remove the .php from www.abcd.com/one.php and not from all the other pages.

I have tried this part in .htaccess file.

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}\.php -f

RewriteRule ^(.*)$ $1.php

Upvotes: 3

Views: 2518

Answers (1)

anubhava
anubhava

Reputation: 785128

You can use this rule in your root .htaccess:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(one)/?$ /$1.php [L,NC]

Upvotes: 6

Related Questions