Forum Moderators: phranque
I'm running on Windows 2003, with IIS and ISAPI_Rewrite 3, so please forgive me :)
Everything with my code below works perfectly, except for images. All of them are broken. I have tried using the full URL, e.g. http://www.example.com/iamges/myimage.gif and I have tried just using a preceding '/' (e.g. /images/myimage.gif
Nothing has worked, the images are still broken.
I am wondering whether it is an IIS issue rather than a Mod Rewrite issue?
RewriteEngine on
RewriteBase /
RewriteMap topic txt:topic.txt
RewriteMap brand txt:brand.txt
RewriteMap series txt:series.txt
RewriteMap model txt:model.txt
RewriteRule ([^/]*)/([^/]*)/([^/]*)/([^/]*)/style/([^/]*)\/ /index2.php?topic=${topic:$1}&brand=${brand:$2}&series=${series:$3}&model=${model:$4}&id=$5
RewriteRule ([^/]*)/([^/]*)/([^/]*)/([^/]*)\/ /index2.php?topic=${topic:$1}&brand=${brand:$2}&series=${series:$3}&model=${model:$4}
RewriteRule ([^/]*)/([^/]*)/([^/]*)\/ /index2.php?topic=${topic:$1}&brand=${brand:$2}&series=${series:$3}
RewriteRule ([^/]*)/([^/]*)\/ /index2.php?topic=${topic:$1}&brand=${brand:$2}
RewriteRule ([^/]*)\/ /index2.php?topic=${topic:$1}
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
Thank you :)
So, if your images are in a subdirectory named "/images", then a request for /images/logo.gif will be rewritten to /index2.php?topic=images and "logo.gif" will be discarded.
So the question is, do you intend for index2.php to serve your images? If not, then I'd suggest excluding any request which includes a filetype in the final path-part from all of your rewrite rules, and using fully-anchored regular-expressions patterns.
Anchoring example:
RewriteRule ^([^/]+)/$ /index2.php?topic=${topic:$1} Also, note that since the question has to do with ISAPI Rewrite, it really belongs in the Microsoft IIS Web Server and ASP.NET forum. If the suggestions above do not help, we can move this thread there.
Jim