0

I want to redirect all the users who enters www.siteA.com/folder1 to www.siteB.com/folder. But user should see www.siteA.com/folder1 in address bas even after redirection to www.siteB.com.

I do not know how to do it with .htaccess Can somebody please help me how to mask the url. I really need your help.

Thanks

user1083644
  • 23
  • 2
  • 8
  • I would recommend to put such kind of configuration directly into your Apache configuration and not use `.htaccess`. In general .htaccess files hurt the performance and should only be used if you have no access to the server configuration and/or need them because of the software you are installing. – bikeshedder Jan 29 '13 at 12:05

2 Answers2

1

You can "Force the substitution URL to be internally sent as a proxy request" via the P flag.

RewriteRule ^folder1(.*) http://www.siteB.com/folder$1 [P]

There are some other examples in the documentation of the RewriteRule.

If this does not work (e.g. no access to the server configuration and the proxy module is disabled) you are probably best of using a Proxy script like PHProxy.

On a second look I think PHProxy is not really what you need. Maybe give this one a try: http://code.google.com/p/php-proxy/ - The installation instructions look pretty simple.

bikeshedder
  • 7,337
  • 1
  • 23
  • 29
  • Thanks. I have used the samething with Rewrite Engine On but its not hiding the url, its getting redirected. i dont know why – user1083644 Jan 29 '13 at 12:27
  • It might be the case that rewrite rules in `.htaccess` files are not allowed to use the `Proxy` flag. Have you tried putting in the Apache configuration as proposed by my comment? – bikeshedder Jan 29 '13 at 12:28
  • No. I haven't tried. Actually i am using a hosted server. Is it possible to access Apache Configuration file on 3rd Party hosted server? Plz help me – user1083644 Jan 29 '13 at 12:39
  • In this case you can not use the builtin Proxy module of Apache. You are probalby best off using a Proxy script: http://sourceforge.net/projects/phpr0xi/ – bikeshedder Jan 29 '13 at 12:55
  • Thanks a lot. I am novice in server management. I have uploaded it to my server, but i am not getting how to use it. Will you please guide me in this. – user1083644 Jan 29 '13 at 13:08
  • You should maybe start another question. On a second look I think PHProxy is not really what you need. Maybe give this one a try: http://code.google.com/p/php-proxy/ - The installation instructions look pretty simple. – bikeshedder Jan 29 '13 at 13:26
  • Hey thanks a ton ton ton!. I have achieved it. Thank you soo much – user1083644 Jan 29 '13 at 13:27
0

You want to use proxying . On Apache, mod_proxy should do what you are looking for.

Bear in mind that your server will eat up twice the amount of bandwidth. Once to get the data from the source server and again to send it to the client.

drone.ah
  • 1,135
  • 14
  • 28