简体   繁体   中英

.htaccess 301 redirect inserting query string

I am trying to organise a simple 301 redirect in my .htaccess file and having some issues.

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/

It redirects okay, though places in a query string: 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. 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. If you are u

也请尝试以下一种方法:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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