[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to redirect just the top page of a dynamic site

Posted on 2010-01-06
2
Medium Priority
?
218 Views
Last Modified: 2012-05-08
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

0
Comment
Question by:kairosmix
2 Comments
 
LVL 51

Accepted Solution

by:
Steve Bink earned 2000 total points
ID: 26197911
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 26198194
what is the condition for the redirect?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
What You Need to Know when Searching for a Webhost Provider
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month18 days, 2 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question