I have a rather simple problem for someone who knows, I just cant find the answer that I need. I have moved to vps and try to configure vm by myself. I need redirects:
I`ve already done .htaccess for www -> non-www, so I have:
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Added A and CNAME:
Added virtualhost
Am I doing right (CNAME, vhost, .htaccess) or it can me done simplier?
Can you please help me redirect *.domain.com -> domain.com (guess in .htaccess) ?
redirect *.domain.com -> domain.com
Just change your rule to this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.(domain\.com)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]
Set your server alias to *.domain.com in your Apache config, below your server name:
ServerName domain.com
ServerAlias *.domain.com
Everything to non-www:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.+)\.domain\.com$ [NC]
RewriteRule ^ http://domain.com/ [L,R]
Everything to www:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.+)\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ http://www.domain.com/ [L,R]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With