问题:访客打开URL的的 website/?i=133r534|213213|12312312 的,但此URL不再有效他们需要转发为的 website/#Videos:133r534|213213|12312312 的
Problem: Visitors open the url website/?i=133r534|213213|12312312 but this url isn't valid anymore and they need to be forwarded to website/#Videos:133r534|213213|12312312
我已经试过:在最后几个小时我试过很多的mod_rewrite(的.htaccess)使用QUERY_STRING规则,都失败了。在这个话题的最后一条消息显示了该问题的解决方案,但会是什么在我的处境规则。
What I've tried: During the last hours I tried many mod_rewrite (.htaccess) rules with using Query_String, all failed. The last message in this topic shows a solution for this problem, but what would be the rule in my situation.
我很好奇,你将如何解决这个问题:!)
I'm very curious how you would solve this problem :)!
推荐答案下面将处理您展示的简单情况。你需要添加额外的逻辑,如果你需要,以便在之前的查询字符串或文件名等参数?
The following will handle the simple case you show. You'll need to add additional logic if you need to allow for other parameters in the query string or file names before the ?.
RewriteEngine On RewriteCond %{QUERY_STRING} ^i=(.*) RewriteRule ^.* /#Video:%1? [NE,R=permanent]
这是为什么棘手?
Why is this tricky?
- 在重写规则不看的查询字符串,所以你必须使用的RewriteCond评估QUERY_STRING变量和捕捉你以后需要的部分(通过参考%1)
- 散列字符(#)通常逃脱,你必须指定[NE]标志
- 的结尾?在替换字符串必须燮preSS原来的查询字符串
我测试了在Apache 2.2。
I tested this on Apache 2.2.
更多推荐
301的.htaccess重写规则QUERY
发布评论