htaccess redirect/rewrite

Discussion in 'Apache' started by rjbathgate, Aug 8, 2010.

  1. #1
    Hey,

    (php/apache server)

    I can't work out how to do the following using htaccess:

    www.domainone.com/folder/filename.php?variables

    redirects/rewrites to

    www.domaintwo.com/filename.php?variables

    but keeping the domain as domainone

    I.e. pulling the file from domaintwo, but keeping the visible domain as domainone

    I thought I should be able to do it with RewriteRule in .htaccess but can't get it to do what I want...

    First step would be to:

    www.domainone.com/folder
    -->
    www.domaintwo.com

    and then adding in the filename.php and ?variables on the end.

    Any help, most appreciated.

    Thanks
     
    rjbathgate, Aug 8, 2010 IP
  2. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #2
    You need mod_proxy installed then in folder put a .htaccess:
    
    RewriteEngine On
    RewriteRule ^(filename.php)$ http://www.domaintwo.com/$1 [P]
    
    Code (markup):
     
    tolra, Aug 8, 2010 IP
  3. rjbathgate

    rjbathgate Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hey,

    Anyway without mod_proxy? Server doesn't, and can't have it installed.

    Cheers
     
    rjbathgate, Aug 8, 2010 IP
  4. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #4
    You need to write a PHP script which is filename.php on the source server which takes the request and then for arguments sake uses curl to send the request to the domaintwo server, collects the output and returns it to the user.

    The PHP script acts as a proxy, however your host might take offence to this if they don't allow proxy scripts as you'll only be billed for 50% of the bandwidth used by the script.
     
    tolra, Aug 8, 2010 IP
  5. romika

    romika Member

    Messages:
    264
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #5
    romika, Aug 24, 2010 IP