homepage Welcome to WebmasterWorld Guest from 54.211.7.174
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
301 directory re-direct
amorosso




msg:4235327
 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..

 

phranque




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

amorosso




msg:4235895
 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]

jdMorgan




msg:4237643
 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.

Jim

amorosso




msg:4237655
 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.

jdMorgan




msg:4239527
 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.

Jim

amorosso




msg:4240794
 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.

g1smd




msg:4240871
 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved