Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I don't understand because this code does not run. foldername is a real folder in /var/www, apache2 runs but browser does not redirect that directory forcing SSL.

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} ^/foldername/.\*
RewriteRule ^(.\*)$ https://host.name.com$1 [R,L]
share|improve this question
    
Is /var/www the DocumentRoot? –  Safado Aug 6 '13 at 13:40
    
Safado: thanks for reply. Yep: /var/www –  Pol Hallen Aug 6 '13 at 13:49
    
OK, just checking. Typically I've seen /var/www as the ServerRoot, but never really the DocumentRoot, which if that were the case the REQUEST_URI condition would need some adjustments. –  Safado Aug 6 '13 at 14:05

2 Answers 2

up vote 3 down vote accepted

It looks like you might have the regular expressions mixed up a bit. Try:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} ^/foldername/.*
RewriteRule ^(.*)$ https://host.name.com$1 [R,L]
share|improve this answer
    
Is it possible not to use "host.name.com" (eg something like RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R,L])? –  coincoin Aug 6 '13 at 14:01
    
Seems that last line (RewriteRule) has ignored... –  Pol Hallen Aug 6 '13 at 14:57

Don't escape the '*' with a '\'.

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} ^/foldername/.*
RewriteRule ^(.*)$ https://host.name.com$1 [R,L]
share|improve this answer
    
host.com.com$1 is example1.org$1? I've done your fix but again does not run :-/ thanks –  Pol Hallen Aug 6 '13 at 13:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.