Home  >  Article  >  Backend Development  >  rewrite 正则 301转为

rewrite 正则 301转为

WBOY
WBOYOriginal
2016-06-13 10:38:23731browse

rewrite 正则 301转向
RewriteCond ^\/index.php.*$ [NC]
RewriteRule ^\/index.php?a=([0-9]+)&b=([0-9]{1})&c=([0-9]+)$ http://zufang.sslook.com/$1/$2/$3 [R=301,L]

以上正则想做的是,访问网站网址为 http://zufang.sslook.com/index.php?a=1&b=2&c=3 自动跳转到页面 http://zufang.sslook.com/1/2/3


请教各位大侠,这个要怎么写? 写来写去都没有成功。

------解决方案--------------------
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^([0-9]+)\/([0-9]{1})\/([0-9]+)$ /test.php?a=$1&b=$2&c=$3 [L,NC]


给你测过了,管用,如假保换

你把后面改为[R=301,L] URL会跟着变,用我的,URL不变
------解决方案--------------------
#3楼是对的,楼主弄反了
------解决方案--------------------
当然是你弄反了!
应该是
浏览器输入 http://zufang.sslook.com/1/2/3 这个网址
就执行 http://zufang.sslook.com/index.php?a=1&b=2&c=3 这个网址

url 重写的结果是供服务器用的,不会返回给浏览器地址栏

如果你的页面中已经写入了动态url,那么应修改的的程序,在页面输出前将动态地址替换成静态地址

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn