Reputation: 15
So I been trying to figure this one out in the htaccess. I have duplicated posts looking like this:
http://test.se/bank/test-b/ http://test.se/bank/test-b-2/
I would like to redirect the posts ending with -2 to the first url.
Ive got this code so far:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^-2/(.*)$ /$1 [L,R=301]`
Upvotes: 1
Views: 32
Reputation: 784888
Your regex is not right as you want to grab everything before -2
not after it:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(.+?)-2$ /$1 [L,R=301]
Upvotes: 1