Reputation: 65
I need to redirect visiters from:
/plug/survey/survey.php?22
to
/publications.php?1.articles.view.547
I have a limited understanding of .htaccess and php and wonder if anyone has any tips/ideas for me? Any help would be very much appreciated!
Thank you
Upvotes: 0
Views: 156
Reputation: 575
I think your solution is
header("location:/publications.php?1.articles.view.547");
You can use .httaccess, but if you want the user should go on that page you cant use it because it will redirect you before reading any code on that page, but header()
will first read the code and if any code is something not good then redirect like this,
if($varisgood){
// not redirect
}
else{
//redirect
}
Upvotes: 0
Reputation: 42885
Your question really lacks vital information:
Where does that "1.articles" come from - is it a fixed string ? where dies that "547" come from, I guess it is from a database lookup somehow ?
If so, there is no easy way to do that using plain rewrite rules. Most likely the best solution is to write a small php script you redirect to. Inside that script you evaluate the request parameters (php variables $_SERVER and so on), make you database lookup and use the information gathered to send a redirect header to the browser (using phps 'header()' method).
Upvotes: 0
Reputation: 46826
Add to the top of survey.php:
<?php
if ($_SERVER['QUERY_STRING'] == "22") {
header("Location: http://example.com/publications.php?1.articles.view.547");
exit;
}
Upvotes: 1
Reputation: 4539
You can write this code in htaccess file
RewriteEngine on
Redirect /plug/survey/survey.php?22 /publications.php?1.articles.view.547
Also read this
http://corz.org/serv/tricks/htaccess2.php
Upvotes: 1
Reputation: 1644
if it is just the one file, you can use header('Location: '.$url); at the top of the php - see http://php.net/manual/en/function.header.php
Upvotes: 0