Just in Chronicles

Life as a Voyage

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 , ,

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s