Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
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?
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
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
Offline
Re: Redirect ?pg=2 to /
Just remove the trailing slash:
RewriteRule ^articles/fork(.*) /articles/fork? [R=301,L]
Offline
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
Pages: 1