简体   繁体   中英

How to rewrite and redirect this url?

How can I rewrite this url:

http://www.mydomain.com/myoldpage.php?proc=my query string (whitespace in mid)

To

http://www.mydomain.com/mynewpage.php

If a user opens old url it should redirect to new one and show content of older one.

Thanks!

add the php code at the top of the myoldpage.php:

<?php header("Location: http://www.mydomain.com/mynewpage.php"); ?>

or if you are going off a certain variable

<?php

if ($_GET['proc'] == "my"){
 header("Location: http://www.mydomain.com/mynewpage.php");
}

?>

Just simply put this in you .htaccess file

RewriteEngine On
RewriteBase /
RewriteRule ^myoldpage.php?proc=my+query+string$ mynewpage.php [PT]

Please tell me if it does not work and I will try to help you :)

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