简体   繁体   English

.htaccess 301重定向插入查询字符串

[英].htaccess 301 redirect inserting query string

I am trying to organise a simple 301 redirect in my .htaccess file and having some issues. 我正在尝试在我的.htaccess文件中组织一个简单的301重定向,并且遇到了一些问题。

My current code looks: 我当前的代码如下:

RewriteRule /contact/ http://www.example.com/connect/ [R=301,L,QSA]

Though when you enter in: http://www.example.com/contact/ 虽然当您输入: http : //www.example.com/contact/

It redirects okay, though places in a query string: http://www.example.com.au/connect/?field=contact 可以重定向,尽管可以放在查询字符串中: http : //www.example.com.au/connect/? field= contact

Which then makes everything blow-up. 然后,这会使一切崩溃。 I have the 301 on the top of my .htaccess file. 我的htaccess文件顶部有301。 I am not sure why this is happening. 我不确定为什么会这样。

Any suggestions would be really appreciated. 任何建议将不胜感激。

RewriteRule ^/?contact/?$ http://www.example.com/connect/? [R=301,L,QSA]

Empty question mark at the end is important as it will discard the original query string from url. 最后的空白问号很重要,因为它将丢弃url中的原始查询字符串。 If you are u 如果你是你

也请尝试以下一种方法:

RewriteRule ^contact/$ http://www.example.com/connect/? [L,R=301]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM