从url中删除php扩展

时间:2013-07-24 14:31:58

标签: .htaccess url mod-rewrite

我有网址example.com/lt.php/example,想删除。example.com/lt/example的.php  我尝试使用htacces,但我认为这是不可能的

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://moliplante.com/folder/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://example.com/folder/$1 [R=301,L]

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

2 个答案:

答案 0 :(得分:2)

这可能有效:

 RewriteRule ^(.+)\.php/(.+)$ $1/$2

第一个反向引用将从lt.php捕获lt,第二个反向引用将有示例,并且将添加php。

答案 1 :(得分:0)

试试这个,希望它能起作用

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