htaccess的:删除扩展名为.php [英] htaccess: Remove .php extension
本文介绍了htaccess的:删除扩展名为.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为Show.php文件
我想删除PHP扩展的这一点,如果有人要求/Show.php,重定向他没有PHP扩展页。
这是我的htaccess的,但没有扩展页面不重定向用户。
的RewriteCond%{REQUEST_URI} ^显示\的.php $
重写规则^显示\的.php $ ./Show [R = 301]
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME!-f
重写规则^显示$ ./Show.php [L]
解决方案
REQUEST_URI
,不像重写规则
前pression,一开始就领先 /
但你的前pression以 ^展
。简单地把领先斜线应该做的工作。其他的一切看起来是正确的。
的RewriteCond%{REQUEST_URI} ^ /显示\的.php $
#------------------------- ^^^^^
重写规则^显示\的.php $展[R = 301]
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME!-f
#Rewrite到Show.php而不是./Show.php
重写规则^显示$ Show.php [L]
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 htaccess but it does not redirect user to without extension page.
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
, 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]
这篇关于htaccess的:删除扩展名为.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文