I'm newbie in Apache Mod Rewrite stuff, I need help to write a rule:
Old pattern:
/{category_id}/{from}/{category_slug}-{page}/{id}/detail-{slug}
New pattern:
/{category_id}-{from}-{category_slug}/{id}-{slug}
The REGEX rules for params are:
id: \d+
category_id: \d+
slug: "^[a-z0-9-]+"
category_slug: "^[a-z0-9-]+"
from: "^[a-z0-9-]+"
page: \d+
I need to write the .htaccess rule to automaticaly redirect old pattern URLs to new ones with a permanent redirect 301.
Example
Old URL:
/2/categorie/tables-bureaux-1/213/detail-secretaire-des-annees-60-domino
Expected new URL:
/2-categorie-tables-bureaux/213-detail-secretaire-des-annees-60-domino
For the moment, I've tried this but it doesn't work:
RewriteCond %{THE_REQUEST} /([0-9]+)/([a-z0-9-]+)/([a-z0-9-]+)-([0-9]+)/([0-9]+)/detail-([a-z0-9-]+) [NC]
RewriteRule /%1-%2-%3/%5-%6$ [R=301,L]
I'm using the PHP Symfony2 framework which already have this .htaccess rule - so I'm not sure where to write the new one:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
Thanks for your help.