Phil
Phil

Reputation: 73

htaccess RewriteEngine working for HTTP but not HTTPS

I am trying to redirect URLs such as www.mysite.com/foo/bar to www.mysite.com/foo/index.php?foo=bar.

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 https://www.mysite.com/foo/bar 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.

Hopefully this extra info might help a bit.

Upvotes: 1

Views: 166

Answers (1)

Phil
Phil

Reputation: 73

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): http://randomtype.ca/blog/the-wordpress-htaccess-file-explained/

Upvotes: 1

Related Questions