Hide file extension (.php) in .htaccess file

后端 未结 3 1635
旧巷少年郎
旧巷少年郎 2021-01-16 23:03

I know there are many topics. I tried them many times, but it doesn\'t work.

What do I want?

Instead of example.com/en/file.php, users see only

相关标签:
3条回答
  • 2021-01-16 23:23

    Perhaps something like this. Modify as you see fit for more specific pattern matching.

    RewriteRule ^(?:(.*)/)?(.*)$ $2.php?lang=$1
    

    Rewrites:

    /en/fun => /fun.php?lang=en

    /ru/fun => /fun.php?lang=ru

    /fun => /fun.php?lang=

    0 讨论(0)
  • 2021-01-16 23:42
    DirectoryIndex index.php index.html    
    
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$      $1.php     [L,QSA]
    

    In your links, don't use extensions.

    0 讨论(0)
  • 2021-01-16 23:42

    Fixed by adding one line:

    RewriteEngine on
    **Options -Multiviews**
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$      $1.php     [L,QSA]
    
    0 讨论(0)
提交回复
热议问题