homepage Welcome to WebmasterWorld Guest from 107.21.187.131
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

    
Dynamic URLs to Root
To redirect dynamic URLs to the root domain
pro_seo




msg:3834955
 6:59 pm on Jan 26, 2009 (gmt 0)

Hello Friends,

This time I am in a fix to redirect some dynamic URLs to the root domain

For example:

example.com/?page_id=9

example.com/?page_id=20

example.com/?page_id=200

example.com/?cat=9

example.com/?cat=20

example.com/?cat=200

all these will redirect to the root domain example.com

Any help on this will be much appreciated...as always :)

 

g1smd




msg:3835064
 8:51 pm on Jan 26, 2009 (gmt 0)

You'll need a
RewriteCond to look at the QUERY_STRING.

Do you want to redirect only those six listed URLs, all URLs with a cat or page_id parameter, or what?

The redirect is fairly simple. The examples in the library will serve to give you what you need.

Post your best effort code back here if you get stuck.

pro_seo




msg:3835372
 6:53 am on Jan 27, 2009 (gmt 0)

hello g1smd! Thanks for your reply.

Do you want to redirect only those six listed URLs, all URLs with a cat or page_id parameter, or what?

I need to redirect all URLs with the cat or page_id parameter in it.

Also can u provide me a link to the library pls?

Thanks a lot again!

jdMorgan




msg:3835658
 2:23 pm on Jan 27, 2009 (gmt 0)

The links to the Forum Charter and the Library are at the top/left of every forum page, including this one. Please review both of those resources for useful information.

Thanks,
Jim

pro_seo




msg:3835820
 5:44 pm on Jan 27, 2009 (gmt 0)

Thanks Jd, I will review and post again if I am stuck anywhere

Thanks!

pro_seo




msg:3839341
 9:50 pm on Jan 31, 2009 (gmt 0)

I browsed through the Library but couldn't find a solution to workaround this issue, maybe I overlooked it but they were too complex for me to grasp.

So it would be really helpful if anyone could guide me in the right direction.

Thanks!

jdMorgan




msg:3839351
 10:07 pm on Jan 31, 2009 (gmt 0)

You'll need a RewriteCond to look at the QUERY_STRING.

I need to redirect all URLs with the cat or page_id parameter in it.

First step:

RewriteCond %{QUERY_STRING} &?(catŠid)=[0-9]+&?

Now it's your turn... What rule do you think you should use?

Have a go. Chin up, bit of effort...

Jim

[edited by: jdMorgan at 10:19 pm (utc) on Jan. 31, 2009]

pro_seo




msg:3839684
 2:31 pm on Feb 1, 2009 (gmt 0)

First step:

RewriteCond %{QUERY_STRING} &?(catŠid)=[0-9]+&?

Now it's your turn... What rule do you think you should use?

Have a go. Chin up, bit of effort...

Wow..this is interesting.

Will it be

RewriteRule ^(catŠpage_id)=[0-9]+ http://www.example.com/ [R=301,L]

Also won't the Query String be

RewriteCond %{QUERY_STRING} &?(catŠpage_id)=[0-9]+&?

Also I would like to know what the & means in the RewriteCond

If the RewriteRule provided by me is wrong, tell me where I went wrong and I will give it another shot.

I really like this approach...this way you just don't spoonfeed but let the other users learn it themselves as well :-)

Thanks a lot Jd

g1smd




msg:3839741
 4:59 pm on Feb 1, 2009 (gmt 0)

The
RewriteRule cannot 'see' the query string, so put the name pf the page in the pattern, or (.*) for 'all' pages. Be as specific as possible, so the rule is checked only when needed, not for every request that hits your server (for images, css, js, etc).

The &? part of the pattern allows for the parameter to be the only parameter, the first or last of several parameters, or somewhere in the middle.

Processing order: is the "left side" of the Rule, followed by the pattern in the Condition if the pattern in the rule was a match.

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