我有一个名为 Show.php 的文件
我想删除这个的 .php 扩展名,如果有人请求 /Show.php,将他重定向到没有 .php 扩展名的页面。
这是我的 htaccess,但它不会将用户重定向到没有扩展名的页面。
RewriteCond %{REQUEST_URI} ^Show\.php$
RewriteRule ^Show\.php$ ./Show [R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^Show$ ./Show.php [L]
REQUEST_URI
, 不像RewriteRule
表达式,以前导开头/
但你的表达开始于^Show
。只需添加前导斜杠即可完成工作。其他一切看起来都是正确的。
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]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)