How to redirect just the top page of a dynamic site

Posted on 2010-01-06
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
Pages underneath are:

Question by:kairosmix
    LVL 50

    Accepted Solution

    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 .* [R,L]
    if (count($_GET)<1) {
      // no data in the querystring

    Open in new window

    LVL 51

    Expert Comment

    what is the condition for the redirect?

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Suggested Solutions

    It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
    Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    730 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now