Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess是否用问号“重写URL?”&引用;_.htaccess_Url_Mod Rewrite - Fatal编程技术网

.htaccess是否用问号“重写URL?”&引用;

.htaccess是否用问号“重写URL?”&引用;,.htaccess,url,mod-rewrite,.htaccess,Url,Mod Rewrite,我的目标是这个网址: component/users/?view=registration 致: .htaccess位于网站的mysite文件夹中 我试过这个: RewriteBase /mysite RewriteRule ^component/users/?view=registration$ registration.html$ [R=301,L] 但是我不工作 当我尝试这个: RewriteRule ^component/users/_view=registration$ regis

我的目标是这个网址:

component/users/?view=registration
致:

.htaccess
位于网站的mysite文件夹中

我试过这个:

RewriteBase /mysite
RewriteRule ^component/users/?view=registration$ registration.html$ [R=301,L]
但是我不工作

当我尝试这个:

RewriteRule ^component/users/_view=registration$ registration.html$ [R=301,L]
它工作得很好

那么我如何用问号来解决这个问题呢。我已经读过了。我已经读到我必须使用类似querystring的东西,但是我没有真正理解语法

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

你需要一个\因为?是正则表达式的一部分。要将其用作字符串,需要使用\


链接提示:

您需要使用
%{QUERY\u STRING}
来捕获查询字符串数据:

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

如果路径
组件/用户
匹配,上述规则/条件将获取查询字符串视图的值,并使用它来形成重定向。

谢谢您的回答,但它不起作用。这是我得到的:当我键入:你知道如何删除这个“?视图=注册”@Bardock请告诉我如何删除“?视图=注册”?不起作用。它仍然会将我重定向到localhost/mysite/component/users/?view=注册:(
RewriteRule ^component/users/\?view=registration$ registration.html$ [R=301,L]
RewriteCond %{QUERY_STRING} ^view=(.*)$
RewriteRule ^component/users/?$ %1.html? [R=301,L]