I don't know very much about .htaccess and rewrite rules, so I've cobbled this together after several days of trial and error.
Basically, I decided I didn't like my blog on a subdomain (blog.mysite.com) and I wanted to streamline it with the rest of the site (mysite.com/blog/). I also wanted to change all the dynamic URLs (mysite.com/blog/archives/view.php?date=2005-02-10&keyword=puppy) to clean URLs (mysite.com/blog/archives/2005/02/10/puppy)
This is how my .htaccess ended up (it's saved in the /blog/ folder):
This works, so I'm basically happy, but I'm just trying to understand the logic of this stuff. Since I am getting rid of the subdomain, I assume the first two RewriteCond and the first RewriteRule have to be in the /blog/ folder in case someone does try to access blog.mysite.com--the /blog/ is acting something like a root folder until the URL redirects it back to mysite.com, right?
I don't understand why the second RewriteRule also has to be in the /blog/ folder instead of the site root. I've tried putting it in the root folder as
--basically, it's the same rule, but with the addition of the /blog/ folder. But it doesn't work--I just get my error page, and when I echo out the referer, I get the fake blog/archives/2005/02/10/puppy URL and not the URL I want it to go to. Yet as soon as I move it to the /blog/ folder, it suddenly works for me. Is there a reason for that? I'm confused.
Granted, it works, so I shouldn't complain, but I hate not understanding things. Does anyone understand rewrite rules enough to know why I can't move the second rule, at least, to the root folder? Does it have something to do with the fact that I've stopped using the subdomain and am redirecting traffic back to the regular mysite.com/blog/ ?
Any help is much appreciated. I'm just trying to understand what's going on.