G
G
gavn0072014-06-15 14:32:19
linux
gavn007, 2014-06-15 14:32:19

RewriteEngine for subdomains

Good afternoon.
Using the example of the article ( How to make subdomains using .htaccess and Apache settings, namely Server Alias ​​*test.ru? ) I am trying to configure RewriteEngine to support subdomains, for example:

aaa.test.su/news/123 -> /home/test/public_html/index.php?domain=aaa&news/123
abc.test.su -> /home/test/public_html/index.php?domain=abc
aaa.test.su -> /home/test/public_html/index.php?domain=aaa

Tell me how to do it right, because the config below returns a 400 error (Bad Request)
<VirtualHost *>

        ServerAdmin [email protected]
        ServerName test.su
        DocumentRoot /home/test/public_html/

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

        <Directory /home/test/public_html>
                AddDefaultCharset utf-8
                AllowOverride None
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kartoshin, 2014-06-19
@kartoshin

$1 is for the one found in the RewriteRule, and the one found in the RewriteCond needs %1.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question