Page 1 of 1

Change only HTTP_HOST section of a URL

Posted: Wed Jun 16, 2010 1:27 am
by markosjal
I am working on making an existing site in dual languages. because each language has its own domain, my idea was to allow a user to click on "English" on a Spanish Page , and visa versa, while holding all of the other file name direcotory, URL variable data etc. This would seamlessly take the to the same page in another language.

so for insrtance if a user is at

mydomain.com/really/deep/directory/file.php?var=1&var2=2&var3=3

I want to be able to make a link ( in PHP?) that takes them to exactly the same page on the other domain

midominio.com/really/deep/directory/file.php?var=1&var2=2&var3=3

now it would seem that the HTTP_HOST is easily enough matched when compared to the URL . How would one find that and replae it in the URL with a new HTTP_HOST value for the link of the new page??

On the alternative we could GET the URL Variables but we would have to define them all , would we not? Can we GET a wildcard variable? or ALL URL variables? That combined with the full path if we could separate the path from the domain.

Any ideas?

Re: Change only HTTP_HOST section of a URL

Posted: Wed Jun 16, 2010 1:34 am
by requinix

Code: Select all

"http://" . $other_domain . $_SERVER["REQUEST_URI"]

Re: Change only HTTP_HOST section of a URL

Posted: Wed Jun 16, 2010 7:45 pm
by markosjal
Exactly what I needed, and it works!

Thanks!