homepage Welcome to WebmasterWorld Guest from 23.22.2.150
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
301 redirect including url parameters
301, redirect
jamalwalsh



 
Msg#: 4477305 posted 10:01 pm on Jul 19, 2012 (gmt 0)

Hello

I need to redirect some sub directories of a site by identifying parameters in the URL

I have several urls I need to 301 redirect to a different site permenatly

EXAMPLE

I would like to redirect 301 the following URLs

www.example.com/test/Z_InitLoginPcode.do?country=GB&language=EN
www.example.com/test/Z_InitLoginPcode.do?country=DE&language=DE
www.example.com/test/Z_InitLoginPcode.do?country=FR&language=FR

There's also the following URL that I want to stay where they are.

www.example.com/test/Z_InitLoginPcode.do?country=ES&language=ES
www.example.com/test/Z_InitLoginPcode.do?country=CH&language=DE
www.example.com/test/Z_InitLoginPcode.do?country=CH&language=FR

And I would like the redirect to go to

www.newexample.net

HELP! Please...

 

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4477305 posted 6:31 am on Jul 20, 2012 (gmt 0)

Read the last few posts in this Forum. It can't be much more than 24 hours since I last posted the boilerplate on query strings (parameters). That will be your starting point.

lc4seo



 
Msg#: 4477305 posted 12:46 pm on Jul 20, 2012 (gmt 0)

Since you want to leave some pages in the /test/ directory you will have to 301 all pages individually on the .htaccess that you want to redirect:

RewriteRule ^test/page-to-keep$ [newsite.com...] [R=301,L]

If you wanted to just 301 the entire directory and add new pages for the ones you want to keep you could use the following:

Rewriterule ^test/(.*) [newdomain.com...] [R=301,L]

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4477305 posted 1:15 pm on Jul 20, 2012 (gmt 0)

Bill. You added a sticky thread a few months ago asking people to use example.com in this forum so that URL auto-linking would be suppressed. Since that request was posted only three or four people have managed to comply with it.

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4477305 posted 9:50 pm on Jul 20, 2012 (gmt 0)

But the OP was one of them-- unless Bill was in a hurry and didn't have time for the "thread tidy" boilerplate-- so let's be nice to him ;)

Just noticed that if you are starting a new topic in this forum, the Sticky will also be visible at the bottom of the screen in the "This Forum: Newer" spot.

lc, he will have to look at the query string, because that's the significant variable. A conditionless Rule won't work. (France and Germany come with him; Swizerland stays put. Heh.)

jamalwalsh



 
Msg#: 4477305 posted 7:30 am on Jul 21, 2012 (gmt 0)

Lucy, you're correct that's exactly what I need to do.

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