R
R
rammsteinik2016-04-07 18:31:57
htaccess
rammsteinik, 2016-04-07 18:31:57

How to create subdomains via htaccess?

It is necessary that the user1.site.rucontent be displayed at the address site.ru/users.php?user=user1. Accordingly, instead of user1, there can be anything. A simple cheap host for 3 acres, that is, there is no access to the insides. I enabled autosubdomains (*.site.ru), the problem is in .htaccess, I don’t know about it.
Should I throw it in the www folder, and not in the root of the site?
It doesn't work like this:

RewriteCond %{HTTP_HOST} ^([a-zA-Z0-9]+\.)?site\.ru 
RewriteRule ^(.*) users.php?user=%1 [L]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rammsteinik, 2016-04-08
@rammsteinik

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.site\.ru$
RewriteCond %{HTTP_HOST} ^(.*)\.site\.ru$
RewriteRule ^(.*)$ http://site.ru/users.php?login=%1 [L,P]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question