I want to write rewrite rule for page url that have no .php extension..

for example http://www.3gphone.in/brands.php into http://www.3gphone.in/brands

Here is my code, but it is not working..

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php

RewriteRule ^/([^/]+)/?$ /$1.php ?

RewriteRule ^/([^/]+)/?$ /$1.php ?

But, its not working

What exactly isn't working? And anyway, what do you want to rewrite to what? Because according to your example I assumed brands -> brands.php, but you said the other way around.

Member Avatar for diafol

Is .htaccess working at all?

Ensure that Rewrite Engine is on.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/([^/]+)/?$ /$1.php

Ensure that Rewrite Engine is on.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/([^/]+)/?$ /$1.php

Still no working..
Here it is complete .htaccess content

Options +FollowSymLinks
Options +Indexes
RewriteEngine on

RewriteCond %{HTTP_HOST} ^3gphone\.in$ [NC]
RewriteRule ^(.*)$ http://www.3gphone.in/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)$ /products.php?pname=$1

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/([^/]+)/?$ /$1.php
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.