hmav25
hmav25

Reputation: 23

Removing .php extension from URL not working

I have added .htaccess file to my directory. When I am writing http://lootainment.in/koovs its working. But when I am writing http://lootainment.in/koovs/ its not working. My htaccess file code is following :-

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php

Upvotes: 0

Views: 52

Answers (3)

anubhava
anubhava

Reputation: 786091

Make trailing slash optional in your rule and remove directory check condition:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.+?)/?$ $1.php

Upvotes: 2

Mohan Nalgire
Mohan Nalgire

Reputation: 25

At first check your php.ini settings for Server API if your server api is 1)apache, 2)apache2filter, 3)apache2handler or like then only you can use .htaccess file. In htaccess file if your php version is php5 then use <IfModule mod_rewrite.c> block to write this code
try this code
RewriteEngine On
# Remove .php-extension from url
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME}\.php -f
 RewriteRule ^([^\.]+)/$ $1.php 

Upvotes: 0

Abhishek Gurjar
Abhishek Gurjar

Reputation: 7476

Try this,

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^([^\.|/]+)$ $1.php [NC,L]

Upvotes: 0

Related Questions