Forum Moderators: phranque
I was wondering if somebody could help me, I have a Wordpress install that puts a base "tag" in the url for each category, but the base tag by itself does not exist. I would like to redirect the non-existent page to a page that does exist. Examples are probably clearer.
Here are urls to two categories
http://www.example.net/category/this-is-my-cat-1/
http://www.example.net/category/this-also-is-my-cat-2/
However if somebody removes the this-is-my-cat-1 bit from the url and just tries to go to http://www.example.net/category/ they get a 404.
How do I redirect http://www.example.net/category/ to http://www.example.net/a-static-page/ while keeping all the original links intact.
The redirects I have tried redirect /category/ as well as anything after, breaking the category links.
Thanks in advance
Regards
Tim
RedirectPermanent /category/ http://www.example.net/my-static-page/
Which matched everything with "/category/" in the url.
Next I tried a redirectmatch
RedirectMatch 301 /category/? http://www.example.net/my-static-page/
And then I tried a few variations on rewrite rules
RewriteRule ^/category/?$ http://www.example.net/my-static-page/
Then I tried something overly complex involving a not match on a-zA-z0-9-_ for anything after /category/, but that mainly ended up as 500 errors!
I found a wordpress plugin which would completely remove the /category/ from all URLs, but I would need a single rewrite rule to then redirect every url containing /category/ to the non-category.
http://www.example.net/category/this-is-my-cat-1/ => http://www.example.net/this-is-my-cat-1/
Would that just be one rule? easier? I guess its better for SEO as the category keywords are closer to the domain.
Thanks for your help
Regards
Tim
RedirectMatch 301 ^/category/?$ http://www.example.com/my-static-page/
Jim