重写 url RewriteRule ^about/ /about.php [L,R=301] 但页面也可以通过 /about.php 直接访问。请帮助如何重定向.php文件
问问题
123 次
3 回答
0
用以下代码替换您的代码:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+about\.php\s [NC]
RewriteRule ^ /about/ [R=302,L]
RewriteRule ^about/?$ /about.php [L,NC]
于 2013-08-02T15:00:15.763 回答
0
于 2013-08-02T15:03:21.970 回答
0
您可以使用规则隐藏重定向:
#use [L] to hidden [R] to shown redirect
RewriteRule ^(about|faq|home)/?$ $1.php [L]
#to prevent access from about.php simply do this:
RewriteRule (.+)\.php$ $1/ [R=301]
#you need to know 301 redirect will be cached with browser for long time
#so if you change rule - will be no effect for some visitors
于 2013-08-02T15:07:05.560 回答