Link to home
Start Free TrialLog in
Avatar of xpandit
xpandit

asked on

Apache2 VirtualHost config

Apache2 listens on wo ports. 80 and 443.

We have one .mobi domain that needs to run on port 80. (The first virtual directory).

All other traffic on port 80 needs to be redirected to a specific domain on port 443. (2nd and 3rd virtual directories respectively).

Basically the first virtual directory doesn't seem to work correctly because even the .mobi domain is being redirected to the domain running on port 443.
<VirtualHost www.domainname.mobi:80>
	ServerAdmin info@domainname.co.za
	ServerName www.domainname.mobi
	ServerAlias domainname.mobi www.domainname.mobi
	DocumentRoot /wwwroot/domainname/www/
	DirectoryIndex m.index.php index.php
	<Directory />
		Options -Indexes
		AllowOverride All
		Order allow,deny
		allow from all
	</Directory>
 
	ErrorLog /var/log/apache2/error.log
 
	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn
 
	CustomLog /var/log/apache2/access.log combined
	ServerSignature Off
 
</VirtualHost>
<VirtualHost 196.***.***.***:80>
	ServerAdmin info@xpandit.co.za
	ServerName www.domainname.co.za
	DocumentRoot /wwwroot/domainname/www/
	<Directory />
		Options -Indexes
		AllowOverride All
		Order allow,deny
		allow from all
	</Directory>
 
	ErrorLog /var/log/apache2/error.log
 
	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn
 
	CustomLog /var/log/apache2/access.log combined
	ServerSignature Off
	RewriteEngine on
	RewriteCond %{SERVER_PORT}      !^443$
	RewriteRule ^/(.*)              https://www.domainname.co.za/$1 [R=301,L]
 
</VirtualHost>
<VirtualHost 196.***.***.***:443>
	ServerAdmin info@xpandit.co.za
	ServerName www.domainname.co.za
	DocumentRoot /wwwroot/domainname/www/
	SSLEngine on
	SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
	SSLProtocol -all +TLSv1 +SSLv3
	SSLCertificateFile /etc/ssl/certs/server.crt
	SSLCertificateKeyFile /etc/ssl/private/server.key	
	<Directory />
		Options -Indexes
		AllowOverride All
		Order allow,deny
		allow from all
	</Directory>
 
	ErrorLog /var/log/apache2/error.log
 
	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn
 
	CustomLog /var/log/apache2/access.log combined
	ServerSignature Off
 
</VirtualHost>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of caterham_www
caterham_www
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xpandit
xpandit

ASKER

Perfect. Thank you.