S
S
sidderman3242018-03-06 19:25:08
htaccess
sidderman324, 2018-03-06 19:25:08

Regional subdomains via htaccess, how to do it via GET?

Good day to all.
On the site I'm trying to organize SEO subdomains by city. So that a person, after choosing a city, is redirected to city.domain.ru. Googled that in .htaccess it is necessary to register such a construction

RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{REQUEST_URI} !index\.php
RewriteCond %{HTTP_HOST} ^(.+?)\.dst.negabarite.work\.ru$
RewriteRule .* /index.php?city=%1 [L]

The idea is to get the city $_GET['city'] then and substitute it in the meta and texts. But the url needs to be exactly like this.
Plus, as I understand it, if you then go to another page, then the choice of the city will be erased. Maybe then somehow write it down in the session. In general, I do not know how best to organize it.
The site runs on WP, plugins and WP Multisite is not suitable for a number of reasons.
Now, when switching to the city.domain.ru subdomain, it redirects back to domain.ru.
Thank you very much in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sidderman324, 2018-03-28
@sidderman324

We solved the issue a little differently by registering Alias ​​on the hosting.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question