regex - Redirect by removing last two letters -


so been trying figure 1 out in htaccess. have duplicated posts looking this:

http://test.se/bank/test-b/ http://test.se/bank/test-b-2/

i redirect posts ending -2 first url.

ive got code far:

options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase /  rewriterule ^-2/(.*)$ /$1 [l,r=301]` 

your regex not right want grab before -2 not after it:

options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase /  rewriterule ^(.+?)-2$ /$1 [l,r=301] 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -