I am completely unfamiliar with .htaccess and have been looking through forums and trying several examples to try and construct a htaccess rule that will solve our problem.
We have had a rule in place to redirect all traffic to the www. version of our domain name which has worked well.
However now we have bought a secure certificate for the URL without the www. Unfortunately no matter how many rules I put in to overwrite the a开发者_运维问答bove rule I can't seem to overwrite it.
Here is our www redirect.
RewriteCond %{HTTP_HOST} !^www.ourwebsite.com.au$ [NC]
RewriteRule ^(.*)$ http://www.ourwebsite.com.au/$1 [L,R=301]
We need to allow the following domain https://ourwebsite.com.au/this-page.html
Does anyone know how I can allow the following URL without affecting the first rule.
Thanks,
Tim
If you're just concerned about not applying that rule when the site is accessed over HTTPS, you can just condition it using the %{HTTPS}
variable:
# Only worry about this rule when HTTPS isn't on
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www.ourwebsite.com.au$ [NC]
RewriteRule ^(.*)$ http://www.ourwebsite.com.au/$1 [L,R=301]
If you decide to apply the www/non-www uniformly for both http/https requests, you can take a look at the examples on the mod_rewrite tag wiki which explain how to accomplish this.
精彩评论