I am needing to translate an unknown subdomain to a variable so the following would apply:
-
http://test.example.com/→http://www.example.com/?domain=test -
http://xyz.example.com/→http://www.example.com/?domain=xyz -
http://www.example.com/→http://www.example.com/ -
http://www.example.com/pageA/→http://www.example.com/pageA/ -
http://fish.example.com/pageB?somevar=something→http://www.example.com/pageB?somevar=something&domain=fish -
http://www.example.com/pageB?somevar=something→http://www.example.com/pageB?somevar=something -
http://fish.example.com/pageB→http://www.example.com/pageB?domain=fish
As you can see all I need to do is replace any subdomain with www and append the subdomain name as a get var called domain.
I’m getting really lost with this.
Edit: Oh I also want the user to still see the subdomain in the url, rather than redirecting.
Try this: