Set Up Local Vhost to Emulate Production Env. - pulibrary/pul_library_drupal GitHub Wiki
alter /etc/hosts
ADD the following to /etc/hosts
127.0.0.1 library.local
Set up vhost
- Turn on name based virtual hosting somewhere in the main apache conf file. In OSX doing this in /etc/apache2/extra/httpd-vhosts.conf is probably easiest.
NameVirtualHost *:80
- Make a default vhost
<VirtualHost *:80>
RewriteEngine On
SSLEngine Off
ServerAdmin [email protected]
ServerName localhost
DocumentRoot /Users/my-user-name/Sites
DirectoryIndex index.html index.php
LogLevel debug
CustomLog /private/var/log/apache2/access_log combined
ErrorLog /private/var/log/apache2/error_log
</VirtualHost>
- Make a vhost for your the dev vhost enviornment
<VirtualHost *:80>
RewriteEngine On
SSLEngine Off
DirectoryIndex index.html index.php
ServerAdmin [email protected]
DocumentRoot "/Users/my-dev-site-path/my-dev-drupal-install-dir"
ServerName library.local
ErrorLog "/private/var/log/apache2/library-core-error_log"
CustomLog "/private/var/log/apache2/library-core-access_log" common
</VirtualHost>
Ignore SSL forcing on local env
Add your local env server name as a ! condition in the .htaccess rules pushing the admin and user paths to SSL
# send certain traffic to https
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} admin|user
RewriteCond %{SERVER_NAME} !library.local
RewriteRule ^(.*)$ https://%{SERVER_NAME}/$1 [R,L]