I pasted below the existing mod_rewrite section of the .htaccess of my Magento site.
I need to modify it to implement a short URL scheme that would redirect all requests like mysite.com/-jk7ASD63
(all short URLs starting with a dash) to mysite.com/cartroute/cartlink?shortcode=jk7ASD63
(long URLs with dash removed).
I believe this is the right line to add (I tested it here https://htaccess.madewithlove.com/):
RewriteRule ^-([a-zA-Z0-9]+)$ cartroute/cartlink?shortcode=$1 [L]
I tried to add this line in various places inside the mod_rewrite section, but everytime it created looping issues that I don't understand... Sure, once the full route is created, it goes through the mod_rewrite again, but why doesn't it redirect to the correct link?
Current mod_rewrite section of the .htaccess:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^api/rest api.php?type=rest [QSA,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
Header set X-Content-Type-Options: nosniff
BrowserMatch \bMSIE\s8 ie8
Header set X-XSS-Protection: "1; mode=block" env=!ie8
</IfModule>
</IfModule>
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !^/index.php/
RewriteRule .* index.php [L]
</IfModule>