代码之家  ›  专栏  ›  技术社区  ›  Kashif Latif

添加使用URL的php扩展。htaccess

  •  0
  • Kashif Latif  · 技术社区  · 9 年前

    https://www.ranglerz.com/about.php
    https://www.ranglerz.com/about
    

    这两个URL现在都在工作,但我想如果用户打开 https://www.ranglerz.com/about https://www.ranglerz.com/about.php

    这是我的

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.+)$ $1.php [NC,L]
    

    我已经尝试了在不同线程中提供的所有解决方案,但都无法解决这个问题。

    1 回复  |  直到 9 年前
        1
  •  2
  •   Croises    9 年前

    您可以使用:

    Options -MultiViews
    
    # Redirect to .php
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^ %{REQUEST_URI}.php [R=301,L]