0

I couldn't find an accurate solution for this on SO.

I have a Wordpress site that needs any URL that contains /blog/?p* to redirect to /blog

The * denotes the wildcard point. So any URL that starts with /blog/?p gets redirected.

I've tried:

RewriteRule ^/blog/?p.*$ http://website.com/blog

But that didn't work.

bort
  • 310
  • 1
  • 2
  • 13

1 Answers1

1

The pattern (the first argument of RewriteRule) only matches the part before the ? (the path). To match the part after the ? (the query string), you need to use a RewriteCond with %{QUERY_STRING}.

So for instance:

RewriteCond %{QUERY_STRING} ^p
RewriteRule ^/?blog/ http://target
anubhava
  • 761,203
  • 64
  • 569
  • 643
jcaron
  • 17,302
  • 6
  • 32
  • 46