However images,css fie etc (anything other than .html) should be redirected to correct place. For example “/article/123/images/picture.jpg” should be redirected to “images/picture.jpg” and “/article/123/site.css” should be redirected to “site.css”.
what rule do I need? I treied a few but I receive server error
2- Where can I find an easy tutorial on regular expressions (specifically with Mod Rewrite format)?
I have written below rules basedon your tutorial. However image etc rules does not work correctly. Is therea way to fix it (instead of using base or explicit path for images etc.)
RewriteEngine on
RewriteRule ^article/([0-9]+)/([a-zA-Z_]+)/([0-9a-zA-Z_]+)$ article.php?id=$1
RewriteRule ^article/([0-9]+)/([a-zA-Z_]+)/([0-9a-zA-Z_]+)/([a-z]+)/(.*?).(ico|gif|jpg|png)$ $4/$5.$6 [L]
Thank you very much again for looking into this and help.
Okay, I recommended the <base> tag over the absolute links (internal over external) and you’ve come up with an obvious third alternative: Using mod_rewrite to redirect images/{whatever}.jpg to {DOCUMENT_ROOT}/images/{whatever}.jpg. HOWEVER, since that’s merely a modification of the absolute option (and a greater load on the server to no useful purpose), I’ll stick with my recommendation (use the <base> tag).
I also thought about server load but I was assuming it is not that considerable. Now that I think, it will need a rewrite for every single image on the site (multiple times more than page requests).