Backup of probably obsolete https://github.com/YOURLS/YOURLS/wiki/Web-Config-IIS
What your web.config file for IIS should look like
If your YOURLS installation is on a IIS machine you have to create a web.config
file. It's simple.
If YOURLS root URL is http://yoursite/
, the web.config
file in the root directory must be like:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering allowDoubleEscaping="true" />
</security>
<rewrite>
<rules>
<rule name="YOURLS" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="/yourls-loader.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
If YOURLS root URL is http://yoursite/somedir/
, the web.config
file in this subdirectory must be like:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering allowDoubleEscaping="true" />
</security>
<rewrite>
<rules>
<rule name="YOURLS" stopProcessing="true">
<match url="^somedir/(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="/somedir/yourls-loader.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Add this before the YOURLS rule block in your web.config
file, replacing yourls.org
with your own domain
<rule name="YOURLS www" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^www\.yourls\.org$" />
</conditions>
<action type="Redirect" url="http://yourls.org/{R:1}" redirectType="Permanent" />
</rule>
This directive MAY or MAY NOT work on your host (ie http://sho.rt/stuff
might work fine and http://www.sho.rt/stuff
might not). If it doesn't work, simply stick to one domain, either with or without www
. There is no real support for both www
and non-www domain setup.
(This is unlikely to get improved, to be honest. I don't get why people insist on adding 4 extra characters (www.
) to their URL shortener...)