简体   繁体   中英

How to redirect based on a value of an query string

When redirecting via php with a query string it also appends the target= part which invalidates the url so how can you redirect without the target= part

i have the following code which redirects successfully but with the target= part

<?php
    header("Status: 301 Moved Permanently");
    header("Location:". $_SERVER['QUERY_STRING']);
    exit;
?>

what i want to happen is for the redirect to work but without the target= part

what actually happens instead is that when the user is accessing http://idk.com/redirect.asp?target=someurl.html the user is redirected to http://idk.com/target=/someurl.html

edit: i also want it to work for both target and TARGET

header('Location: /'. $_GET['target']);

It sounds like this is what you're looking for.

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