Forum Topic: Redirect noob question

Forum: .htaccess Forum : Redirecting • Posted by binalogue SL • Updated:


I’ve got a wordpress site and I wanted to add a shortcut as follows.

Redirect 301 /jobs/

This works great.

The issue is now that I have a category called news, and for some reason all posts* are now also redirected to* which should only be the case if I was using RedirectMatch, correct?

So I’m wondering if there is a conflict, or if wordpress is doing something that I am not considering.

Also struggling with redirecting all subpages of a folder to its parentpage. So to speak a */foldername/**/foldername/

1 Reply to “Redirect noob question”

Posted by Jeff Starr

That is the correct functionality for Redirect, as explained in the Apache docs:

“The Redirect directive maps an old URL into a new one by asking the client to refetch the resource at the new location.”

It then gives an example of Redirect:

Redirect /service

..and goes on to say about this directive:

“If the client requests, it will be told to access instead.”

So in the case you’ve described, the posts are redirected as expected. To limit the redirect it’s possible to use RedirectMatch.

For the redirecting of all subpages to the parent directory, using mod_rewrite will help avoid recursive loops:

# place in root .htaccess
<IfModule mod_rewrite.c>
	RewriteCond %{REQUEST_URI} !/foldername/$ [NC]
	RewriteCond %{REQUEST_URI} /foldername/(.*) [NC]
	RewriteRule .* [R=301,L]

Test thoroughly, let me know how it goes!


– Jeff