0

So I have moved on to using Azure, and unfortunately Azure doesnt have Static IP address. I have setup a micro AWS instance and installed apache on it.

I am looking to setup a default virtual host (for any sites which are not named by hostname) and redirect any traffic to the AWS APache server to www.name.com

I am looking for a rule that does this:

http://domain1.com 302 redirect to http://www.domain1.com?src=naked-domain

http://domain2.net 302 redirect to http://www.domain2.net?src=naked-domain

Essentially its just a 302 redirect for every single domain which a virtual host doesnt exist for.

Frank
  • 1,056
  • 3
  • 17
  • 38
  • duplicate of: http://stackoverflow.com/questions/1100343/apache-redirect-from-non-www-to-www – Pedro L. Aug 31 '13 at 22:43
  • Trying to get it with wildcard domain name. So it works for any a record that is forwareded to the server. Say i have 1000 domains at godaddy, just create a records with the server Ip and it forwards to to www. The "duplicate" is for a named host. – Frank Aug 31 '13 at 22:46

1 Answers1

0
Options +FollowSymLinks
RewriteEngine on


RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Frank
  • 1,056
  • 3
  • 17
  • 38