-4

I have one serveur with multiple domains. I'd like to redirect only one "site-internet.com" to ssl configuration.

I'd like to do :

This is my apache conf file

NameVirtualHost *:80

<VirtualHost *:80>
    RewriteEngine on

    RewriteCond %{HTTP_HOST} ^test.site-internet\.com$[NC]
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ http://test.site-internet.com/$1 [NC,R=301,L]

    RewriteCond %{HTTP_HOST} ^(.*)\.site-internet\.com$
    RewriteCond %{HTTP_HOST} ^site-internet\.com$
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301]
</VirtualHost>

But this don't work. What should I correct ?

SOf Virtual
  • 153
  • 1
  • 7
  • @LatinSuD The "NC" flag is just one flag, not two separate flags. It's all very well documented on Apache's website, so there's no need for random baseless guessing. – Chris S Aug 21 '14 at 13:59

1 Answers1

6

So when you put 2 RewriteConds, they are "AND"-ed, meaning they both need to be true in order to apply the RewriteRule. You need to use [OR] to overcome this. Also, I don't get why you need the code for "not redirecting".

<VirtualHost *:80>
    RewriteEngine on

    RewriteCond %{HTTP_HOST} ^www\.site-internet\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^site-internet\.com$
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301]
</VirtualHost>
Florin Asăvoaie
  • 6,932
  • 22
  • 35