homepage Welcome to WebmasterWorld Guest from 54.204.249.184
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Broken images using ISAPI Rewrite 3 on IIS
ish




msg:3721041
 12:40 pm on Aug 12, 2008 (gmt 0)

Hi everyone

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 :)

 

jdMorgan




msg:3721339
 6:23 pm on Aug 12, 2008 (gmt 0)

I note that none of the regular-expressions patterns in your rules which rewrite to index2.php have anchors. This can cause trouble. In particular your last rule, which passes only "topic" will accept *any* URL for any resource located in any subdirectory, use the subdirectory as "topic", and discard anything that follows it in the requested URL.

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

ish




msg:3723355
 10:18 pm on Aug 14, 2008 (gmt 0)

Thank you Jim. You've pointed me in the right direction, with partial success. Next week I will be back on the case to get it working 100% :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved