What's wrong with these redirect rules?

RewriteEngine On  
RewriteBase /  
RewriteCond %{HTTP_HOST} =www.pointfixed.com  
RewriteCond %{HTTPS} on  
RewriteRule ^$ http://www.pointfixed.com/ [L,R=301] 

What I'm trying to do with these rules is forward HTTPS to HTTP for the root of the www domain only.

Just that URL and no more than that. No subdirectory redirects, etc. Just if someone tries to access the base URL https forward to http.

Anyone know what I'm doing wrong?

  • You don't actually state what happens? An error? Incorrect redirect? Nothing? These directives look OK. Make sure you've cleared all caches before testing and test with 302 (temporary) redirects until it works as desired. – MrWhite Feb 28 '19 at 1:47

You can also do it via:

RewriteEngine on
RewriteBase /
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} =www.example.tld
RewriteRule ^$ http://%{HTTP_HOST}

That one should work as expected (it did on my domain), hopefully. And meet the criteria of the question this time.

  • I was going to say the same but then I saw "Just those urls and no more than that. No subdirectory redirects, etc. Just if someone tries to access the base url https forward to http." ... so (.*) won't do what he wants. – ETL Apr 19 '13 at 0:23
  • Yeah, this isn't exactly what I'm asking for. I'm looking for just the root. – Dan Rice Apr 19 '13 at 0:32
  • Whoops, yeah, right you are. Edited to reflect the actual question. – nerve Apr 19 '13 at 0:55
  • Thanks this worked after a few days. I think my host was caching the htaccess file. – Dan Rice Apr 22 '13 at 17:50
  • This is really no different to the code the OP provided in the question. Except this will result in a 302 (temporary) redirect and cause processing to continue through the file due to the lack of the L flag. (Rather than the host caching the .htaccess file, it's more likely that your browser was caching the old redirect.) – MrWhite Feb 28 '19 at 1:41
RewriteRule ^$ http://www.pointfixed.com/ [L,R=301]

That would mean rewrite "" to http://...

^ means start of string. $ means end of string.

You probably meant

RewriteRule ^/$ http://www.pointfixed.com/ [L,R=301]
  • I tried that, but it doesn't seem to be working. I am still able to view the https site. I would try on another domain, but this is the only domain I own that has https. Also , it's a dynamic cloud managed site so I can't look at the .htaccess log. I'm wondering if it's just a bug with my provider. – Dan Rice Apr 19 '13 at 0:31
  • Do you have any other configuration somewhere? I never myself used the .htaccess to control things on Apache as I use it only for proxying so maybe the issue is along the lines on how to put this in the .htaccess file. – ETL Apr 19 '13 at 0:37
  • It's working now! Looks like there was a caching delay and now after a few days it started working. – Dan Rice Apr 22 '13 at 17:49
  • The regex ^/$ would never match in a per-directory (.htaccess) context. The "odd looking" empty match ^$ is correct here. – MrWhite Feb 28 '19 at 1:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.