apache - Mod_rewrite combine default path with www. and https redirect -
i'm trying reduce number of redirects on our website. managed combine of our redirect code (forcing www. , https://), need add default path (/en/) in case there none.
rewritecond %{https} off [or] rewritecond %{http_host} !^www\. [nc] rewriterule (.*) https://www.example.com%{request_uri} [r=301,l]
the other bit of code want implement this:
rewriterule "^/$" /en/
so if there's no path or arguments given, needs redirect /en/. (now in php, meaning every person typing "example.com" gets 2 redirects, 1 should enough)
my goal combine these rules 1 single redirect. possible?
finally, have internal rewrite rule, irrelevant question above, i'll add completeness:
rewriterule "(^|/)\." - [f] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$/? index.php?rewrite=$1 [qsa]
should work:
rewritecond %{https} off [or] rewritecond %{http_host} !^www\. [nc] rewritecond %{request_uri} ^/$ rewriterule (.*) https://www.example.com/en%{request_uri} [r=301,l] rewritecond %{https} off [or] rewritecond %{http_host} !^www\. [nc] rewriterule (.*) https://www.example.com%{request_uri} [r=301,l]
Comments
Post a Comment