| 10:38 am on Nov 28, 2010 (gmt 0)|
welcome to WebmasterWorld [webmasterworld.com], amorosso!
there are many threads covering that subject in the Apache Web Server forum at WebmasterWorld.
this one might be close to your solution - .htaccess to redirect /directory/ to subdomain:
| 11:40 am on Nov 28, 2010 (gmt 0)|
Hi and thank you so much. That was very very close to what I'm looking for. However I need to catch anything going to in this example "blog"
RewriteRule ^blog/(.*)$ http://blog.example.com/$1 [R=301,L]
So anything like www.blog.com/anything to http://blog.example.com Can this be done. I searched and searched but I can't find anything.. Thanks again.
[edited by: tedster at 6:55 pm (utc) on Nov 28, 2010]
[edit reason] make examples visible [/edit]
| 11:27 pm on Dec 1, 2010 (gmt 0)|
You need to understand the code before you can use it or modify it. See the resources cited in our Apache forum charter and the examples in our Apache Forum Library.
If you remove "blog/" from the RewriteRule pattern, it will redirect *all* requests to blog.example.com. However, be very sure that that is really what you want, because it will make the originally-requested domain inaccessible.
| 11:41 pm on Dec 1, 2010 (gmt 0)|
Thank you. Yea what I'm looking to do because Google has so so many of blog/..... what ever to just one. So many urls into just one would be good enough.
| 1:29 am on Dec 7, 2010 (gmt 0)|
The parentheses in the rules above capture the "whatever else follows 'blog' value" and the $1 in the substitution URL "copies" that captured value. So this is a many-to-many rule, and not a many-to-one rule at all.
You have to read the RewriteRule and regular expressions documentation (see our Apache Forum Charter for links) at a bare minimum to understand this stuff, and proceeding without understand --and thorough understanding, at that-- can reasonably be termed "suicide" at worst and "potentially very expensive" at best. One little logic error, omission, or typo can utterly sink your site -- functionally, search-ranking-wise, or both.
| 1:35 am on Dec 10, 2010 (gmt 0)|
Ya know you're right. I'll have to either make a 301 for each url or read my butt off and learn more of what I need to do.. Thank you so much.
| 8:09 am on Dec 10, 2010 (gmt 0)|
The usage of .* pattern in parentheses and the $1 backreference means that it handles EVERY request arriving at the site, so no there is no need to make a redirect for each URL. The code already does that.