I am trying to configure apache to redirect to www and https on our server, we use an ecom package that uses a vlink script which resides in a cgi-bin folder.
The instructions to rewrite /cgi-bin/scriptname to / are:-
RewriteEngine on
RewriteRule ^$ /cgi-bin/scriptname/ [L,NS,PT]
RewriteRule ^/$ /cgi-bin/scriptname/ [L,NS,PT]
RewriteRule ^/index\.html$ /cgi-bin/scriptname/ [L,NS,PT]
RewriteCond /home/scriptname/www/html/%{REQUEST_FILENAME} -f [OR]
RewriteCond /home/scriptname/www/html/%{REQUEST_FILENAME} -d
RewriteRule ^(.+)$ - [L,NS]
RewriteCond /%{REQUEST_FILENAME} !^.*/cgi-bin/scriptname.*$
RewriteRule ^(.+)$ /cgi-bin/scriptname/$1 [L,NS,PT]
I have this in both the :80 and :443 vhost sections in the apache conf.
Now I want to make sure that all urls redirect to https and www so I added this into .htaccess
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
It seems to work but when I look at what happens using wget I see multiple 301 permanently moved, sometimes 3 or 4 depending on the url, some referring to /cgi-bin/scriptname
Is this correct, I was thinking I should just see a single 301 moved followed by a 200?