简体   繁体   中英

How do i do a 301 redirect from a dynamic url with query string to base url?

I want to redirect this link: http://www.kuraikaze.com/?awt_l=KN6HU&awt_m=41Jd85ntcrWHhWh to my site's base url at http://www.kuraikaze.com

Any ideas how to go about this? I've tried Rewrite and Redirect but it's not working.

All Help is very much appreciated!

Thanks!

you can use header function.

Check link http://www.php.net/manual/en/function.header.php

Place this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} (^|&)awt_l=KN6HU&awt_m=41Jd85ntcrWHhWh(&|$) [NC]
RewriteRule ^/?$ /? [L,R=301]

UPDATE: To make it dynamic:

RewriteCond %{QUERY_STRING} (^|&)awt_l=[^&]*&awt_m=[^&]*(&|$) [NC]
RewriteRule ^/?$ /? [L,R=301]

Reference: Apache mod_rewrite Introduction

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