Welcome to WebmasterWorld Guest from 54.211.86.24

Forum Moderators: Ocean10000 & incrediBILL & phranque

301 directory re-direct

   
4:30 pm on Nov 26, 2010 (gmt 0)



Hi, I'm trying to make a 301 redirect so anything /FORUM-BLOG/*.* would get redirected to a different dir. I would like to use a sub domain that is diyforum.askmediy.com is there anyway to make it like a wildcard . So anything that comes in after /FORUM-BLOG/ would just get redirected.

Thanks in advance..
10:38 am on Nov 28, 2010 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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:
http://www.webmasterworld.com/apache/4116291.htm [webmasterworld.com]
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)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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.

Jim
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)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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.

Jim
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)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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.
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month