我有以下隐藏.htaccess
扩展名的.php
文件。也就是说,它不是显示http://address/info.php
,而是显示http://address/info
。
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
在htaccess
文件中,我需要添加phpinformation
(这是一个愚蠢的链接 - 不会去任何地方:http://address/phpinformation
)重定向到info
。也就是说,http://address/phpinformation
需要重定向到http://address/info
我应该如何修改代码?
答案 0 :(得分:0)
你能试试吗
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteCond %{REMOTE_ADDR} ^192\.168\.1\.120
RewriteRule ^phpinformation\.php /info.php [R,NC,L]
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]