htaccess的重定向URL参数作为段

编程入门 行业动态 更新时间:2024-10-22 18:36:17
本文介绍了htaccess的重定向URL参数作为段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否有可能重定向URL参数在.htaccess文件片段?

测试/的index.php?参数= myvalue的

测试/ myvalue的/

解决方案

是的。试试这个:

的RewriteCond%{QUERY_STRING}参数=(。*) 重写规则测试/索引\ .PHP测试/%1

据什么是匹配的?在之后的 mod_rewrite的文档,查询字​​符串(部分?)中分离到的 QUERY_STRING 变量,然后必须单独从URL的主要部分进行测试。在的RewriteCond ,该参数值由常规的前pression括号内捕获(。*),并随后可通过%1 在重写规则。

Is it possible to redirect url parameters as segments in .htaccess file?

i.e.

test/index.php?parameter=MYVALUE

to

test/MYVALUE/

解决方案

Yes. Try this:

RewriteCond %{QUERY_STRING} parameter=(.*) RewriteRule test/index\.php test/%1

According to "What is matched?" in the mod_rewrite docs, the query string (part after the ?) is separated out into the QUERY_STRING variable, which then has to be tested separately from the main part of the URL. In RewriteCond, the parameter value is captured by the regular expression within the parentheses (.*), and is then available as %1 in the RewriteRule.

更多推荐

htaccess的重定向URL参数作为段

本文发布于:2023-11-01 11:45:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549257.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   参数   htaccess   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!