Forum Moderators: phranque
RewriteRule content/([0-9]+)/([0-9]+)/([a-z\-]+)/(.+)\.htm(l?)$ /index.php?action=artikel&cat=$1&id=$2&artlang=$3 [R=301,L,QSA]
RewriteCond %{THE_REQUEST} \?action=artikel&cat=([0-9]+)&id=([0-9]+)&artlang=([a-z-]+)
RewriteRule ^index\.php$ /content/$1/$2/$3/SOMETHING.html [R=302,L]
RewriteRule ^content/(\d+)/(\d+)/([a-z\-]+)/([^/.]+)\.html?$ /index.php?action=artikel&cat=$1&id=$2&artlang=$3 [L,QSA]
the last part of the request is simply thrown away, meaning that ANY kind of garbage would lead to valid content. Ta-daa, infinite URL space. Or was this a posting typo and there's really something like 302's aren't cached
You would never normally (externally) redirect from the "user-friendly" URL to the "ugly" (real) URL.
Although, I'm a bit stuck what "SOMETHING" should be? You don't have a 4th backreference in your original substitution, so it's not possible to "reverse" without some more information?
The QSA frankly worries me, because it implies that the original URL--the one that's supposed to be short and pretty--might also contain parameters.
When I write my own redirect code (301), it's always the "old" URL, followed by the desired one.
Now, I did come across rewrite rules where the desired URL is first, followed by the one we want to escape from, but never understood the difference between my 301 rules and such.
RewriteCond %{THE_REQUEST} long-ugly-URL
RewriteRule long-ugly-URL http://example.com/short-pretty-URL [R=301,L]
RewriteRule short-pretty-URL /long-ugly-URL [L]
In your htaccess, make sure all the redirects ([R=301,L] flag) come first, with all the rewrites ([L] flag alone) later.