short story: I'm new to apache (and sysadministration in general) and trying to redirect a subdomain to my main domain. I already have a rewrite rule that get rid of the 'www.' subdomain.
long story: My old site went down. I rebuilded it. There was a subdomain to that old site: forum.mydomain.com. Now, it does not exists anymore. A person who access my site by forum.mydomain.com should be redirected to mydomain.com.
I'm using .htaccess file. That's what my hoster allows me to use.
Here's what in it: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^mydomain.com$ [NC] RewriteRule ^(.*)$ http://mydomain.com/$1 [L,R=301]
if the host is not mydomain.com, redirect to mydomain.com. Shouldn't forum.mydomain.com fit in the condition?
I know it's probably been asked, but I did not found any question where they are in my situation. And since I already have a hard time understanding the rule above, I'd prefer to have someone who knows wants he talks about than me doing hit and miss.
Now for the optional part of the question, if someone could explain to me the rule above, it would be great.
Here's what I understand in the above rule:
if the host is NOT mydomain.com ( !^mydomain.com$ ) redirect to http://mydomain.com.
What I don't understand is the first part of the rule regex: ^(.*)$, and then the reference to it ($1). How come matching everything can be put as the requested file path? Wouldn't it do something like that: "http://mydomain.com/http://www.mydomain.com/%5Brequested file]"?
Thank a LOT to everyone.