Reputation: 744
While updating things in WordPress I found that plugins that generate slugs can't use a slug that's already in use by another page so I have had to change the slug to be something slightly different. I now need to make sure that anyone that tries the old urls get redirected to the new one without affecting the main page.
So I have /members/
with a list of members and you can click members to go to /member/[name]
I need to redirect /members/[name]
to the /member/[name]
( [name] can be anything so it needs to be a wildcard.)
I have used both of the following htaccess rules (not at the same time) but they always end up redirecting the /members/ page also which breaks everything.
RewriteRule ^members/(.*) http://domain.tld/member [R=301,L]
RedirectMatch 301 ^/members/.*$ http://domain.tld/member
What am I missing to make it only redirect if there's something after the /
Sidenote: I've tried finding an answer to this but all the results I have found are trying to do the exact opposite (redirecting only the exact match of /members/) that I need and wont work.
Upvotes: 1
Views: 34
Reputation: 41249
You are not using the captured part of the request.
Try :
RedirectMatch ^/members/(.+)$ /member/$1
Upvotes: 1
Reputation: 316
Try this
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Redirect 301 /oldDir/old.php http://yourDomain/newDir/new.php
Upvotes: 0