R
R
Roman2016-03-19 13:51:34
linux
Roman, 2016-03-19 13:51:34

Apache2 rewrite. How to remake?

Good afternoon!
There is a config

<VirtualHost site.ru:80>
        ServerAdmin [email protected]
        ServerName site.ru
        ServerAlias www.site.ru
        DocumentRoot /var/www/site.ru/
        <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
        </IfModule>

<Directory /var/www/site.ru/>
AllowOverride All
</Directory>

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

Redirects all requests to https.
The idea was that everyone who came to site.ru went to https://site.ru, it seems to work...
But, now, if someone comes to test.site.ru , they should stay there... and they are transferred to https :(
I can’t master these regular expressions at a glance .... Tell me where you can read about them? Or what to correct, and why exactly :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor Taran, 2016-03-21
@shambler81

use negation.

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^(www\.|)test\.site\.ru$ [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question