Remove php extension from url

前端 未结 2 1328
陌清茗
陌清茗 2021-01-27 23:39

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

相关标签:
2条回答
  • 2021-01-27 23:58

    Try this, hope it will work

    RewriteEngine on 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME}\.php -f 
    RewriteRule ^(.*)$ $1.php
    
    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题