in Development, Internet, Microsoft


If you’re running YOURLS on an IIS 7 box you’ll need the correct settings in your web.config to perform the URL Rewriting. An example web.config with the correct settings is below.

Note the security section which disables some paranoid protection IIS has switched on by default. If your server doesn’t allow double escaping of request strings, the YOURLS links with a + in them don’t work. This breaks the admin interface and the stats reporting pages.

The rest of the web.config is standard stuff to fix a non-canonical hostname, and make sure the IDs are rewritten to the right pages:

		<requestFiltering allowDoubleEscaping="true" />
		<rule name="Canonical Host Name" stopProcessing="true">
			<match url="(.*)" />
				<add input="{HTTP_HOST}" negate="true" pattern="^domain\.com$" />
			<action type="Redirect" url="{R:1}" redirectType="Permanent" />
		<rule name="YOURLS 1" stopProcessing="true">
			<match url="^([0-9A-Za-z]+)/?$" ignoreCase="false" />
			<conditions logicalGrouping="MatchAll">
				<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
				<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
			<action type="Rewrite" url="/yourls-go.php?id={R:1}" appendQueryString="false" />
		<rule name="YOURLS 2" stopProcessing="true">
			<match url="^([0-9A-Za-z]+)\+/?$" ignoreCase="false" />
			<action type="Rewrite" url="/yourls-infos.php?id={R:1}" appendQueryString="false" />
		<rule name="YOURLS 3" stopProcessing="true">
			<match url="^([0-9A-Za-z]+)\+all/?$" ignoreCase="false" />
			<action type="Rewrite" url="/yourls-infos.php?id={R:1}&amp;all=1" appendQueryString="false" />