删除PHP扩展名的URL [英] Remove php extension from url
本文介绍了删除PHP扩展名的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有网址 example.com/lt.php/example
,并希望删除的.php,这将是 example.com/lt/example
我尝试用htacces,但我认为这是不可能的。
RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^([^ /] +)/ $ http://moliplante.com/folder/$1 [R = 301,L]
的RewriteCond%{THE_REQUEST} ^(。+)\。PHP([#?] [^ \] *)?\ HTTP /
重写规则^(。+)\。PHP $ http://example.com/folder/$1 [R = 301,L]
重写规则^([^ /] +)$ $ 1.PHP [L]
解决方案
这可能工作:
重写规则^(。+)\。PHP /(.+)$ $ 1 / $ 2
第一个反向引用会捕获其中从lt.php和第二反向引用将有榜样,PHP将被添加到它。
I have url example.com/lt.php/example
and want remove .php that will be example.com/lt/example
I try with htacces, but I think that's impossible
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]
解决方案
This might work:
RewriteRule ^(.+)\.php/(.+)$ $1/$2
The first backreference would capture lt from lt.php and the second backreference would have example and php would be added to it.
这篇关于删除PHP扩展名的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文