2

I am trying to get my website to redirect to

www.domain.tld/folder/

from

www.domain.tld/folder/index.php?params=blah&param2=etc

I have tried:

header("Location: /")

But all it does is redirect me to

www.domain.tld

Does anyone know how to redirect properly to just the folder?

9
  • 1
    Have you thought about using your .htaccess file to do this? Commented Sep 19, 2013 at 6:42
  • @Leptonator I don't want every page to do it...Only some. I use the params to redirect around, then, at the final page, i just want it to change to /folder/ Commented Sep 19, 2013 at 6:42
  • header('Location: http://www.domain.tld/folder/') ? Commented Sep 19, 2013 at 6:43
  • @phil it a dynamic domain Commented Sep 19, 2013 at 6:43
  • try header("Location: /folder/") then Commented Sep 19, 2013 at 6:43

2 Answers 2

4

header("location: ./");

will do the job, but you will face infinite redirection because of index.php if there is no if condition for specific case such as ?params=blah&param2=etc

Sign up to request clarification or add additional context in comments.

Comments

1

Just to clarify the above answer you can place check for query string in the index.php as

 <?php
      if ( ($_GET['params'] == 'blah') && ($_GET['param2'] == 'etc') ) {
           header("location: ./");
           exit;
      }  
 ?>

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.