Tag Info

Hot answers tagged


Your conditions are implicitly AND'd and your second condition will always be true (unless you have other domains), so your current rules will only redirect non-SSL traffic. You need to OR the conditions and negate the www (second) condition: RewriteEngine On RewriteCond %{SERVER_PORT} !=443 [OR] RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ ...


Add another condition to exclude the subdomain: RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} !^i\. RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] Presumably the www canonicalisation is already handled elsewhere? This should probably be a 301 (permanent) redirect, rather than a 302 (temporary). There is no need to ...


With your additional domains pointing to subdirectories off the main domain's document root, you can add the following to the .htaccess in that subdirectory to redirect to the main domain: RewriteEngine On RewriteRule (.*) https://maindomain.com/$1 [R=302,L] Note that this uses mod_rewrite, not mod_alias (Redirect). As such it will override the ...


I found the solution. 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]

Only top voted, non community-wiki answers of a minimum length are eligible