PHP/Apache2: How do I redirect ./index.php?facebook to ./facebook.php? [duplicate]

Possible Duplicate:
Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?

Is it possible to redirect ./index.php?facebook to ./facebook.php? If so, how to do this?

Many thanks in advance,

Answer

There are at least two ways to do it.

  • With Apache’s mod_rewrite:
    RewriteEngine On
    RewriteCond %{QUERY_STRING} =facebook [NC]
    RewriteRule (.*)/index.php$ $1/facebook.php [R,L]
  • Within the index.php PHP script itself (my PHP is very rusty; consider this to be pseudo-code):
    if (isset($_GET['facebook'])) {
        header('Location: facebook.php');
        exit;
    }

Attribution
Source : Link , Question Author : Eamorr , Answer Author : Steven Monday

Leave a Comment