Remove .php from URL

后端 未结 11 937
生来不讨喜
生来不讨喜 2020-12-15 22:17

Ubuntu 14.04LTS 32bit

LAMP

I know it\'s an old question but..

I need it to remove .php anywhere it finds it from the visible url. It needs to work wi

11条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 22:22

    Assuming that .htaccess is being processed, then this super simple .htaccess should work for you:

    RewriteEngine on
    RewriteRule (.*) $1.php [END]
    

    If it doesn't work, there is something wrong with your Apache configuration. You need to look into that first.

    If it works, add the following line before the RewriteRule to allow serving other files:

    RewriteCond %{REQUEST_FILENAME} !-f
    

    The END flag is available since Apache 2.3.9.

提交回复
热议问题