URL重写和重定向 [英] URL Rewrite and redirect
本文介绍了URL重写和重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到一个小问题,我想同时放置重写URL和重定向规则.例如,当有人打开abc.html时,我想显示abc.php的内容,这可以通过URL重写来完成:
I am having a small issue, I want to place rewrite url and redirect rule both. For example, I want to show content of abc.php when someone open abc.html and this can be done with url rewriting:
RewriteEngine On
RewriteRule ^abc\.html$ abc.php [NC,L]
但是,如果有人直接在浏览器中打开abc.php,我想在abc.html上发送它们,当我放置301重定向时,它将无法正常工作,因为它会生成循环.
But what if some one opens abc.php directly in browser, I want to send them on abc.html and when I place 301 redirect it doesn't work as it generates loop.
我该怎么做?
推荐答案
您可以使用:
RewriteEngine On
RewriteCond %{THE_REQUEST} /abc\.php[\s?] [NC]
RewriteRule ^ /abc.html [R=301,L]
RewriteRule ^abc\.html$ abc.php [NC,L]
这篇关于URL重写和重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文