htaccess: Remove .php extension

前端 未结 1 1947
轮回少年
轮回少年 2021-01-24 21:09

i have a file named Show.php

i want to remove .php extension of this, and if someone requested /Show.php, redirect him to without .php extension Page.

This is my

1条回答
  •  不知归路
    2021-01-24 21:58

    REQUEST_URI, unlike the RewriteRule expression, begins with a leading / but your expression begins with ^Show. Simply adding the leading slash should do the job. Everything else looks correct.

    RewriteCond %{REQUEST_URI} ^/Show\.php$
    #-------------------------^^^^^
    RewriteRule ^Show\.php$ Show [R=301]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    #Rewrite to Show.php rather than ./Show.php
    RewriteRule ^Show$ Show.php [L]
    

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