Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7546051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:05:56+00:00 2026-05-30T09:05:56+00:00

Suppose I want to redirect all GET queries from one site to another, using

  • 0

Suppose I want to redirect all GET queries from one site to another, using PHP.
POST queries do not exist in the system.

For example, when the user connects to

www.mysite.com/index.php?action=myAction&pageno=2

I want him to be redirected to:

www.mySecondSite.com/index.php?action=myAction&pageno=2

I can get write a hard-coded code for each and every possible $_GET variable (myAction and pageno in my example), but it does not sound like a reasonable solution. Also, I’ve seen this solution which involves modifying the configuration of the Apache server. Suppose I can’t change the server configuration.

For sure, there must be a way to get all of the variables and their values, and redirect it to another site.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:05:58+00:00Added an answer on May 30, 2026 at 9:05 am

    First of all you need to get complete URL, for example for my local server:

    http://localhost/server_var.php?foo=bar&second=something
    

    Try printing $_SERVER variable with print_r():

    print_r( $_SERVER);
    

    You should get result like this:

    Array
    (
        ...
        [REQUEST_URI] => /server_var.php?foo=bar&second=something
        ...
    )
    

    For more info take a look at manual page, so now you have your URL:

    $url = 'http://www.mySecondSite.com' . $_SERVER['REQUEST_URI'];
    

    And you can use header() to redirect your request:

    header( 'Location: ' . $url);
    

    I recommend taking look at HTTP status codes, 3xx ones, whether you want to use 302 Found (the default) or 307 Temporary Redirect…

    The second special case is the “Location:” header. Not only does it
    send this header back to the browser, but it also returns a REDIRECT
    (302) status code to the browser unless the 201 or a 3xx status code
    has already been set.

    So you can do this:

    header('HTTP/1.0 307 Temporary Redirect');
    header( 'Location: ' . $url);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php website and I'm using mod_rewrite to redirect all of the
I want to redirect to other view from view.ctp . Suppose like this =>
Suppose I have a url http://www.somesite.com/path/to/catalyst/controller And I want to redirect this to http://www.somesite.com/extra-part/path/to/catalyst/controller
Suppose I want to allow to select our entity (from a dropdown, etc) on
Suppose I want www.example.com/profile to redirect a user to his or her profile page.
Suppose I want to call a subprocess from within my program, and I want
What is the best practice for implementing the Post/Redirect/Get pattern in ASP.NET MVC? In
<form action=??? method=POST> <input type=text name=content> </form> Suppose I'm using Backbone.js's routes feature, and
I have all traffic from port 50 redirected to 5050 using iptables -t nat
I'm not a very experienced programmer, and am using CodeIgniter for second time. Suppose

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.