Redirect exact url

Discussion in 'Apache' started by gldigital, Jan 6, 2015.

  1. #1
    I'm using a .htaccess file to redirect only example.com/script-dir/index.php (with www and without) to example.com/index.php, but it also redirects example.com/script-dir/index.php?page=faq and other pages.

    What should I do to redirect only that single page?
     
    gldigital, Jan 6, 2015 IP
  2. mikebvm

    mikebvm Active Member

    Messages:
    76
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    98
    #2
    You can do a 301 redirect in PHP. Any way you can make this sort of code only show up in just the one you want to redirect?

    <?php header("HTTP/1.1 301 Moved Permanently"); header("Location: http://example.com/index.php"); ?>
     
    mikebvm, Jan 14, 2015 IP
  3. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #3
    For the suggestion above, I'd suggest just checking to see if $_GET['page'] is set, and if it's not, or empty, redirect.
     
    PoPSiCLe, Jan 15, 2015 IP