0

I am running multiple virtual hosts on a local machine running Ubuntu 14.04 and Apache2. Let's assume that the project I am trying to access has the ServerName directive set to website.local When I try to access it in the browser with website.local the browser is immediately redirected to https://website.local and then fails to connect.

I think I found a potential cause but I am not sure. When I first setup the project it contained an .htaccess file with the following rewrite rules

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

these were in place from the production environment. I removed them but the issue persisted.

As a test I setup a new virtual host test.local pointing to the same project directory, but this time I made sure that the rewrite rules were not there before enabling the virtual host in Apache. This time the project loaded without a problem at test.local.

It seems then in my limited experience, that Apache is somehow 'remembering' the rewrite rules for the old virtual host. I tried disabling and enabling the host and reloading Apache but no dice.

Is my suggestion indeed the problem and so how do I fix it? Or am I completely missing the real underlying issue here

Pankrates
  • 125
  • 1
  • 7

0 Answers0