Welcome to WebmasterWorld Guest from 54.198.87.238

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Dynamic URLs to Root

To redirect dynamic URLs to the root domain

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

5+ Year Member



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

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

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



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.

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

5+ Year Member



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!

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

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



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

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

5+ Year Member



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

Thanks!

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

5+ Year Member



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!

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

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



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]

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

5+ Year Member



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

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

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



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.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month