.htaccess - apache mod rewrite (all HTTP requests to HTTPs) -


after setting letsencrypt on vps these rewrite conditions set letsencrypt:

rewriteengine on rewritecond %{server_name} =xy.com [or] rewritecond %{server_name} =www.xy.com rewriterule ^ https://%{server_name}%{request_uri} [end,qsa,r=permanent] 

it works fine, redirect requests 'https://www.xy.com https too. tried using code:

rewriteengine on rewritecond %{server_name} =xy.com [or] rewritecond %{server_name} =www.xy.com [or] rewritecond %{server_name} =https://www.xy.com rewriterule ^ https://%{server_name}%{request_uri} [end,qsa,r=permanent] 

it doesn't work. idea do?

none of answers worked. here's file placed in www/html/xy/public folder. requests point this, don't know if maybe causes problem?

<ifmodule mod_rewrite.c> <ifmodule mod_negotiation.c>     options -multiviews </ifmodule>  rewriteengine on  # redirect trailing slashes if not folder... rewritecond %{request_filename} !-d rewriterule ^(.*)/$ /$1 [l,r=301]  # handle front controller... rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ index.php [l]  # handle authorization header rewritecond %{http:authorization} . rewriterule .* - [e=http_authorization:%{http:authorization}] </ifmodule> 

try :

rewriteengine on   rewritecond %{https} off [or] rewritecond %{http_host} ^www\.(.+) rewriterule ^ https://%1%{request_uri} [nc,l] 

this redirect both http or www https://

or can use :

rewriteengine on rewritecond %{server_name} ^(?:www\.)?(xy)\.com$ rewriterule ^ https://%1%{request_uri} [end,qsa,r=permanent] 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -