Reputation: 63
I have a lot incorrect back links, the links are pointing to:
while the correct path is
there are hundreds of those...how could i 301 redirect from the wrong links to the correct links?
Thank you so much in advance
Upvotes: 1
Views: 521
Reputation: 5748
You can try this code:
RewriteBase /
RewriteRule ^tags/([^/]+)$ /tags/$1/ [L,R=301]
RewriteBase /
tells apache that your URI starts by a /
. If your site was in a subfolder you should write RewriteBase /subfolder/
instead.^tags/([^/]+)$
: you search for an URI starting with tags/
followed by [^/]+
that means any characters except /
. The ( )
around it are there to capture it and use it in the redirection. So we capture any characters that are not /
between tags/.../
in the URI. (^
marks the start of the string while $
marks the end)/tags/$1/
is the redirection. $1
means the first previous captured element (the one witch was between ( )
).[L,R=301]
indicates to apache that it should stop process other rules and redirect with a 301 header code.Upvotes: 1