从URL中删除.php扩展名无效

时间:2016-09-28 09:34:09

标签: php .htaccess

我已将.htaccess文件添加到我的目录中。当我写http://lootainment.in/koovs时它正在工作。但是当我写http://lootainment.in/koovs/时它不起作用。我的htaccess文件代码如下: -

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

3 个答案:

答案 0 :(得分:2)

在规则中使尾随斜杠可选并删除目录检查条件:

RewriteEngine on

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

答案 1 :(得分:0)

试试这个,

persist:false

答案 2 :(得分:0)

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