Just in Chronicles

Life as a Voyage

Posts Tagged ‘FancyBox

When Getting 404 Error While Using FancyBox 1.3.4 jQuery Plugin

leave a comment »

According to the article http://stackoverflow.com/questions/6591288/im-getting-404-errors-with-fancybox-images, there are 404 errors occur while using the FancyBox 1.3.4 jQuery plugin. I had the exact same errors and, because of this, my IIS has almost gone down to write server error logs.

In order to fix this issue, without modifying the plugin core, simply add the URL rewrite rule into your web.config.

<configuration>
	...
	<system.webServer>
		...
		<rewrite>
			<rules>
				...
				<rule name="Fancybox image path correction" stopProcessing="true">
					<!--
						Assumptions:
						- the page URL is http://yoursite.com/contents/pagename.html
						- the 404 error happens when the server tries to access to http://yoursite.com/contents/fancybox/image_file_name.png
						- FancyBox jQuery plugin is located under /scripts/jquery.fancybox-1.3.4
					-->
					<match url="^contents/fancybox/(.+).png$" />
					<action type="Rewrite" url="/scripts/jquery.fancybox-1.3.4/fancybox/{R:1}.png" />
				</rule>
				...
			</rules>
		</rewrite>
		...
	</system.webServer>
	...
</configuration>

Node that this is just a workaround, not the solution. The best thing is modifying the plugin core.

Advertisements

Written by Justin Yoo

10/05/2012 at 12:37

Posted in For Web

Tagged with , ,