I have a site called: www.example.com this is the main domain. Now I have a Alias: www.example2.com.I want that example2.com will be forwarded to a subdomain of the main domain to subdomain.example.com.I used following code:RewriteEngine OnRewriteCond %{HTTP_HOST} ^(www\?example2\.com$ [NC]RewriteRule ^(.*)$ http://subdomain.example.com/ [R=301,L]I got an 500 Internal Server Error. And i really don't know why.
.htaccess rewrite rule domain alias doesn't work
htaccess;mod rewrite;url rewriting;multiple domains
As w3d suggested in the comments, you have an open parenthesis, but not one to close itRewriteEngine OnRewriteCond %{HTTP_HOST} ^(www\?sek-muenchenstein\.ch$ [NC]# right here -------------^RewriteRule ^(.*)$ http://muenchenstein.sek-am.ch/ [R=301,L]Also, in the COND line, you have www\?. I think this might be wrong too, it's now literally looking for the ? in the url, like below, which is highly unlikely: www?sek-muenchenstein.chIf you want the alias to redirect, just test without www.Also also, if you are at siteA.com/example you will end up at siteB.com, without /example.Code with all suggestions:RewriteEngine OnRewriteCond %{HTTP_HOST} sek-muenchenstein\.ch$ [NC]RewriteRule ^(.*)$ http://muenchenstein.sek-am.ch/$1 [R=301,L]#  Take ------^ and put it ------------------------^^Or, if you plan ahead and there are multiple alias, reverse the check:RewriteEngine On# if not maindomain:RewriteCond %{HTTP_HOST} !muenchenstein.sek-am.ch$ [NC]RewriteRule ^(.*)$ http://muenchenstein.sek-am.ch/$1 [R=301,L]Try to make your regexes less detailed. It's easier to read the less you add, and less prone to errors. And changes are less likely to mess things up, eg adding a subdomain. Your code will stop working because of the www, mine wont.