tags:

views:

656

answers:

4

I want to redirect from:

domain1.com/photos

To:

domain2.com/photos

I want the URL in the address bar to still read:

domain1.com/photos.

Is there a way to do this using only .htaccess?


Note:

My .htaccess file for domain1.com is currently completely blank.

+2  A: 

No, there isn't a way to do this with .htaccess. Doing so would present a glaring security hole - imagine someone doing this with a bank's website!

ceejayoz
Yeah that makes since...its just domain1.com is a free hosting account which injects a banner on the top of every page...problem is its making a flex app not work right...so I was trying to host the flex app elsewhere.
John Isaacks
A: 

A way around it, if the page at domain.com/photos is a server side script, do a http call and server up the response.

In ColdFusion:

<cfhttp url="another.domain.com/photos">

<cfoutput>#CFHTTP.FileContent#</cfoutput>

They'll be an extra request, but it'll get you the output you want.

Adrian Lynch
in PHP you can quickly use readfile: http://fr.php.net/manual/fr/function.readfile.php
streetpc
Only if remote fopen is enabled, though.
ceejayoz
+1  A: 

If you own both domain1 and domain2, you could accomplish this through domain name forwarding. Check your domain name registrar (like godaddy.com) for the options.

No, you can not do it through htaccess file.

Ryan Oberoi
Thanks but I only want to forward domain/photos not the entire domain.
John Isaacks
+1  A: 

You could open an iframe in domain1.com/photos that shows the contents of domain2.com/photos. But then the url would never change from domain1.com/photos, even when you went to a different page in domain2.

What are you trying to do? It sounds very sketchy. Do you own both domains? Why would you want to duplicate the contents of one site at another address?

Cameron
I do own both domains...I gave a description of why I want to do this in ceejayoz's answer. Thanks.
John Isaacks