apache - Redirect non-www and non-https to https://www -


i want redirect non-www , non-https urls https://www domain, have following htaccess, works ok redirecting non-https https still allows access domain.com without www,

rewriteengine on rewritecond %{https} !=on rewriterule .* https://%{server_name}%{request_uri}%{query_string} [l,r]  # redirect trailing slashes... rewriterule ^(.*)/$ /$1 [l,r=301]  # handle front controller... rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ index.php [l] 

i've found should use following force www, can't should placed best, thanks

rewritecond %{http_host} !^www. [nc] rewritecond %{http_host} ^(.+)$ [nc] rewriterule ^(.*)$ http://www.%1/$1 [r=301,l] 

you can use:

rewriteengine on  rewritecond %{https} off [or] rewritecond %{http_host} !^www\. [nc] rewriterule ^ https://www.domain.com%{request_uri} [r=301,l,ne]  # remove trailing slashes... rewritecond %{request_filename} !-d rewritecond %{the_request} \s(.+?)/+[?\s] rewriterule ^(.+?)/$ /$1 [r=301,l,ne]  # handle front controller... rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ index.php [l] 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -