htaccess RewriteEngine working for HTTP but not HTTPS

I am trying to redirect URLs such as to

To do this I am using a couple of lines in the .htaccess file, they are as follows:

RewriteEngine On
RewriteRule    ^foo/([a-z]+)/?$    foo/index.php?bar=$1 [NC,L]

This works great for connections made over HTTP but I really need this to work over HTTPS as well. When I go to I just get presented with the 404 Not Found error page.

Any help to get this working over HTTPS (or an explanation as to why it cannot be done over HTTPS) would be great. Thanks.

EDIT: After reading a few comments here is a bit of an update.

  • I do have an SSL certificate for the site and HTTPS is working fine elsewhere on the site
  • The document root is the same for both the HTTPS and the HTTP versions of the site. I checked this out using echo $_SERVER['DOCUMENT_ROOT']; - both return the same thing.
  • I did notice that (when I removed my customised 404 page) that the error shown is: The requested URL document_root/public_html/foo/index.php was not found on this server. I do not have any idea why this might be the case when, if I access the file directly, I can use it fine.

Hopefully this extra info might help a bit.


After some more searching for solutions and looking at examples of .htaccess files I found the solution. I needed to add the following line to my .htaccess file:

RewriteBase /

I am still unsure as to why, without this line, it worked using HTTP but not HTTPS but everything is working well with the addition of this line.

I am no expert in this area but I found a nice explanation of what RewriteBase does here (Line 4):

Need Your Help

In Excel, how do I reference a local worksheet within a template?

excel templates reference

I am creating my own template which I need to use data from a worksheet called Schedules. The template contains 3 sheets, none of which are the Schedules sheet. This template will only be used in

What version of .Net framework should be targeted for end user apps

c# .net

I am writing a little application in android which would have a server part in .Net (C#). Obviously I want to target maximum number of end users, without having to deal with no framework installed ...