Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-02-17 20:39:07

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Redirect ?pg=2 to /

I had duplicate articles and the search engines already crawled them so I am trying to redirect /articles/fork/?pg=2 to articles/fork

I’ve tried a few things such as:
RewriteRule ^fork/?pg=2$ /fork [L,R=301]

but I can’t get anything to work. Any ideas?


BB6 Band My band
Gud One My blog

Offline

#2 2008-02-17 22:41:08

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: Redirect ?pg=2 to /

The correct way to do this looks like this:

 RewriteCond %{REQUEST_URI} /(fork)/(\?pg=\d+)
 RewriteRule /(fork)/(\?pg=\d+) http://www.example.com/fork [L,R=301]

Note: You need to escape the Questionmark in a regular expression.

( Replace www.example.com with your domain name)

In the above example also all other pages are redirected to the fork frontpage.
If you don’t want this, then replace \d+ with 2.

Also, I think it is more convenient to use zem_redirect.

regards, marios

Last edited by marios (2008-02-17 22:43:32)


⌃ ⇧ < ⌃ ⇧ >

Offline

#3 2008-02-17 22:45:55

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Redirect ?pg=2 to /

You do realize redirecting fork/?pg=X to fork/ will prevent you from accessing fork/?pg=X, right? In any case:

RewriteEngine On
RewriteCond %{QUERY_STRING} !^$
RewriteRule ^articles/fork(.*) /articles/fork/? [R=301,L]

Last edited by jm (2008-02-17 22:48:46)

Offline

#4 2008-02-17 23:07:30

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: Redirect ?pg=2 to /

Thank you, jm! Marios, it just kept going to ?pg=2, like it did with all my other attempts.

jm, it redirects to /fork/ which will do for me. The original article was /fork but I couldn’t find a way to redirect to that.


BB6 Band My band
Gud One My blog

Offline

#5 2008-02-17 23:12:58

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Redirect ?pg=2 to /

Just remove the trailing slash:

RewriteRule ^articles/fork(.*) /articles/fork? [R=301,L]

Offline

#6 2008-02-17 23:16:22

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: Redirect ?pg=2 to /

jm, you’re the man!


BB6 Band My band
Gud One My blog

Offline

#7 2008-02-18 02:06:58

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: Redirect ?pg=2 to /

Sorry @zero. ( Example totally wrong ) I must’nt have slept very well.

regards, marios


⌃ ⇧ < ⌃ ⇧ >

Offline

Board footer

Powered by FluxBB