0

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

4
  • 2
    Are you using Apache? Read about mod_rewrite? What have you tried? Commented Jul 13, 2012 at 11:50
  • 3
    Then you should read about ;) and learn. Commented Jul 13, 2012 at 11:50
  • .htaccess won't work because both links have nothing in common, you must do it with PHP or other server side language. Commented Jul 13, 2012 at 11:51
  • Possible duplicate of How to make a redirect in PHP? Commented Dec 3, 2015 at 11:00

5 Answers 5

1

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;
}
Sign up to request clarification or add additional context in comments.

Comments

1

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

2 Comments

For redirecting users you should use(add) R flag
Thank you very much, but putting this in .htaccess gives me a 500 internal server error. Is there anything I might be doing wrong?
0

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

Comments

0

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).

Comments

0

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
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.