0

I have a couple of hits everyday from a now defunct tutorial I wrote. Rather than letting them sit on the 404, I have created a page with links to more up to date ones in the hope that someone else can help.

I am attempting to edit my htaccess to rediret

My site is WP powered and the incoming link is

/tutorials/?p=3

I would like it to go to:

/wiki/sorry-this-tutorial-no-longer-exists 

I have tried:

Redirect /tutorials/?p=3 http://domain.com/wiki/sorry-this-tutorial-no-longer-exists 

The closest I got was

RedirectMatch 301 ^/tutorials/?(.*)  http://domain.com/wiki/sorry-this-tutorial-no-longer-exists 

But that of course sticks the ...exists/?p=3 on the end which doesn't work

Any help with the bloody question mark? (I tried htaccess url rewrite with question mark but it would not work?)

Community
  • 1
  • 1
tjh
  • 89
  • 1
  • 6

1 Answers1

1

I believe this should do what you are looking for

RewriteEngine on
RewriteCond %{REQUEST_URI}  ^/tutorials/$
RewriteCond %{QUERY_STRING} ^p=3
RewriteRule ^(.*)$ http://domain.com/wiki/sorry-this-tutorial-no-longer-exists? [R=302,L]
Anigel
  • 3,435
  • 1
  • 17
  • 23
  • Yes, this looks more like it. However, this still gives me a http://domain.com/wiki/sorry-this-tutorial-no-longer-exists/?p=3 result. Anyway to remove the ?p=3 – tjh May 03 '12 at 11:21
  • Apologies I missed the ? off the end. I have updated the answer – Anigel May 03 '12 at 12:51
  • 1
    just a detail but use `^\bp=3\b` otherwise query patterns like `?cab=300` will get matched. – TerryE May 03 '12 at 14:34
  • Good stuff! Works perfectly now. Many thanks for the fix and @TerryE for the tweak. – tjh May 03 '12 at 16:29