Tag Archive for htaccess

.htaccess SSL rewrite not working – DocumentRoot in Apache Config – WordPress Multi-site

I wasted a good couple of hours on this one, please learn from my fail.

I had just set up SSL on our WordPress Sites and that was working as expected, what was not working as expected was the rewrite from HTTP to HTTPS where a directory or path was involved.

So http://mysite.com/thispath would end up going to: https://mysite.comthispath

The slash separating the domain and directory\path would be taken out, so any existing Google links would also be very broken.

After much trial and error with various plugins and variations of the rewrite rules in the .htaccess file, I had a lightbulb moment when I was checking my Apache config.

I had set up the VirtualHost for port 80 traffic(HTTP) without a DocumentRoot, so when I would come in on http://mysite.com it could not find the .htaccess file to properly process the rewrite rules.  As far as Apache knew, there were no rewrite rules to process.  Which still begs the question, why does it remove the slash between the domain and the directory\path, that I don’t know….

What I do know: Make sure you specify a DocumentRoot in your Apache config, under VirtualHost in my case, for the type of traffic you want to process any rewrite rules for!

Otherwise, you’re gonna have a bad time… I had not seen any comments around this in my searches, so here it is, I hope it saves someone some pain.