JosephGarrone
JosephGarrone

Reputation: 4161

Redirect from /folder/index.php to /folder/

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?

Upvotes: 2

Views: 118

Answers (2)

asarfraz
asarfraz

Reputation: 518

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;
      }  
 ?>

Upvotes: 1

Jason OOO
Jason OOO

Reputation: 3552

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

Upvotes: 4

Related Questions