使用 .htaccess 重定向错误 [英] Redirecting error using .htaccess

查看:54
本文介绍了使用 .htaccess 重定向错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

重写url RewriteRule ^about//about.php [L,R=301] 但页面也直接通过/about.php 访问.请帮助如何重定向 .php 文件

rewriting the url RewriteRule ^about/ /about.php [L,R=301] but the page is accessed via /about.php directly also. Please help to how to redirect .php file

推荐答案

您可以使用规则隐藏重定向:

You can use rule to hidden redirect:

#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

这篇关于使用 .htaccess 重定向错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆