P
P
Pepper12019-08-15 18:08:18
htaccess
Pepper1, 2019-08-15 18:08:18

How to get a GET parameter from a subdomain?

Hello!
I decided to make a subdomain on my site for each city. Previously, he received a city and an article. - site.ru/city/article. I received parameters in htaccess, before -
RewriteRule ^(.*)/(.*).html$ index.php?city=$1&articles=$2 [L]
everything worked.
Now the structure is like this - city.site.ru/article.
Now I'm doing like this -
RewriteRule ^(.*).site.ru/(.*).html$ index.php?city=$1&articles=$2 [L] - doesn't work, but it should

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-08-15
@Pepper1

RewriteCond %{HTTP_HOST} ^(?>www\.|)([^.]+)\.site\.ru$ [NC]
RewriteRule ^(.*)\.html$ index.php?city=%1&articles=$1 [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question