How to redirect just the top page of a dynamic site

I need to have the top page of a dynamic site that uses index.php, redirect to another site, different name, different server. I need to have the pages underneath remain the same.

So, I have a site http://www.mysite.com/index.php
Pages underneath are: http://www.mysite.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=52

kairosmixAsked:
Who is Participating?
 
Steve BinkCommented:
The easiest way would be to put code at the top of index.php to detect the querystring.  If none is found, use header() to redirect to the alternate location, otherwise continue execution.  See the code snippet for an example.

You can also do this with mod_rewrite.  Use RewriteCond to check for the querystring content.  A very basic example:

# if no query string exists, redirect
RewriteCond %{QUERY_STRING} !^.+$
RewriteRule .* http://some.other.domain.com [R,L]
<?
if (count($_GET)<1) {
  // no data in the querystring
  header('Location: http://some.other.domain.com');
  die();
}
?>

Open in new window

0
 
ahoffmannCommented:
what is the condition for the redirect?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.