Answer the question
In order to leave comments, you need to log in
How to go to a subdomain without changing the current page?
Guys, hello everyone. I am writing here to you, because I don’t even know how to correctly google my question.
I have a site test.ru And a subdomain moscow.test.ru
They have the same directory.
I have a button - switch subdomains. Accordingly , test.ru and moscow.test.ru The
question is how to implement such a logic of switching to a subdomain so that if I am on the page
test.ru/information/law/
When I click on the button to go to the subdomain, I do not go to the main one - but remain on / information/law/
I was thinking of doing this:
$poddomen = $_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"]
Answer the question
In order to leave comments, you need to log in
Your question has several solutions.
The most obvious:
1. Make a redirect to the address of the page you need when you click on the button. This can be done on the javascript side, but if you need a solution, php parse_url () will help you.
2. Store the value of the desired page in a session variable.
3. Change the address of the page using javascript through the history api, in fact, without leaving it
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question