htaccess的重写URL一个问号"?" [英] .htaccess rewrite URL with a question mark "?"

查看:846
本文介绍了htaccess的重写URL一个问号"?"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是这个网址:

component/users/?view=registration

要:

registration.html

的.htaccess 是网站的文件夹mysite的。

the .htaccess is in the folder mysite of the website.

我想这样的:

RewriteBase /mysite
RewriteRule ^component/users/?view=registration$ registration.html$ [R=301,L]

但我不工作...

But i doesnt work...

当我尝试这样的:

RewriteRule ^component/users/_view=registration$ registration.html$ [R=301,L]

它工作得很好。

it works very well.

那么,如何解决这个问题的问号。我已经读过这就是它是不是URL的一部分(其附加)。我已阅读,我必须使用类似查询字符串,但我真的不明白的语法。

So how can i fix this problem with the question mark. I already read thats it is not a part of the URL (its appended). I have read that i have to use something like querystring, but i didn't really understand the syntax.

也许有人能写出这个问题的解决方案?将是真棒=)

Maybe someone could write the solution of this problem? Would be awesome =)

推荐答案

您需要使用%{QUERY_STRING} 捕捉查询字符串数据:

You need to use %{QUERY_STRING} to capture the query string data:

RewriteCond %{QUERY_STRING} ^view=(.*)$
RewriteRule ^component/users/?$ %1.html? [R=301,L]

以上规则/条件将查询字符串观点的价值,并用它来形成你的重定向,如果路径组件/用户相匹配。

这篇关于htaccess的重写URL一个问号"?"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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