A
A
Artyom2014-01-02 15:21:56
PHP
Artyom, 2014-01-02 15:21:56

How to make subdomains using .htaccess and Apache settings, namely Server Alias ​​*test.ru?

Hello!
A very interesting question arose, at least for me. How to make subdomains using .htaccess and Apache settings, namely Server Alias ​​*test.ru.
There are a lot of ready-made solutions for subdomains from folders, for example, convert test.ru/sub using .htaccess to the sub.test.ru subdomain.
But mine is a little different. There is one page folder, it contains an index.php file. If we turn to a file with a GET request, for example test.ru/page/?t=test, we will get the content of the page. So Here's how to make pages open at test.art-gur.ru, where test is a GET request.
I got something like this code.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.art-gur.ru
RewriteCond %{HTTP_HOST} ([^.]+)\.art-gur.ru
RewriteRule ^index\.php(.*)$ /page/?t=%1 [L,QSA]

But it doesn't work, I know that something seems to be wrong with me, but I don't know what.
Thank you in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
fenric, 2014-01-03
@art_gur

RewriteEngine On
RewriteCond %{HTTP_HOST} ^([0-9a-zA-Z_\-]+)\.example\.com$
RewriteRule ^(.*)$ index.php?subdomane=$1 [L]

Try this example, and based on it, proceed further ...
PS I really hope that support for subdomains at the HTTP server level is resolved...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question