Enabling Search Engine Friendly (SEF) URLs on IIS: Difference between revisions
From Joomla! Documentation
m moved SEF URLs on IIS to Enabling Search Engine Friendly (SEF) URLs on IIS: Adapted page title to the continuous tense used in most tutorial titles. |
Split off Joomla 1.0 content to Enabling Search Engine Friendly (SEF) URLs on IIS/IIS6/1.0 |
||
| Line 80: | Line 80: | ||
} | } | ||
</source> | </source> | ||
<noinclude>[[Category:IIS]][[Category:Tips and tricks]][[Category:Search Engine Friendly URLs|IIS]]</noinclude> | <noinclude>[[Category:IIS]][[Category:Tips and tricks]][[Category:Search Engine Friendly URLs|IIS]]</noinclude> | ||
Revision as of 14:51, 9 June 2011
Under IIS7, a native URL Rewite module is available. It stores rules in a site's web.config file, expressed in XML format. .htaccess rules can be converted to the web.config format.
Under IIS6, a third-party add-on must be used. Helicon provides one which directly supports .htaccess rules.
IIS 7 URL Rewriting
If you have a server running IIS 7 and PHP, you can take advantage of IIS's own internal URL rewriting by using a web.config file similar to the one listed below.
You can create the file yourself or use the GUI in the IIS7 Manager. You can import .htaccess rules using the GUI/wizard.
This functionality depends on the presence of the IIS URL Rewrite Module, which does not come with Windows. It is a free download and a Microsoft product.
GUI
If the IIS URL Rewrite module is installed, your website manager will have a tool for "URL Rewrite", visible in the IIS Manager's view of your site's configurable IIS modules. The interface is largely self-explanatory. Regular expressions, wildcards or exact matches are all supported.
In the Joomla config turn on both the SEF and Apache mod_rewrite, next create a rule under IIS URL Rewrite:
- Pattern field: ^([^/]+)/?$
- Ignore case ON
- Action type: Rewrite
- Rewrite URL: index.php/
web.config
This has been tested on Joomla 1.5 with IIS 7 on Windows Server 2008 with no problems so far. For more information on converting .htaccess to web.config, check out http://learn.iis.net/page.aspx/557/translate-htaccess-content-to-iis-webconfig/
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Common Exploit Blocking" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAny">
<add input="{QUERY_STRING}" pattern="mosConfig_[a-zA-Z_]{1,21}(=|\%3D)" />
<add input="{QUERY_STRING}" pattern="base64_encode.*\(.*\)" />
<add input="{QUERY_STRING}" pattern="(\<|%3C).*script.*(\>|%3E)" />
<add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" />
<add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" />
</conditions>
<action type="Redirect" url="index.php" appendQueryString="false" redirectType="SeeOther" />
</rule>
<rule name="Joomla Search Rule" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{URL}" pattern="^/search.php" ignoreCase="true" />
</conditions>
<action type="Rewrite" url="/index.php?option=com_content&view=article&id=4" />
</rule>
<rule name="Joomla Main Rewrite Rule" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{URL}" pattern="(/[^.]*|\.(php|html?|feed|pdf|raw))$" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/" />
</rule>
</rules>
</rewrite>
<caching>
<profiles>
<add extension=".php" policy="DisableCache" kernelCachePolicy="DisableCache" />
</profiles>
</caching>
</system.webServer>
</configuration>
Helicon ISAPI Rewrite
Helicon ISAPI Rewrite 3 located at http://www.helicontech.com/isapi_rewrite/ now provides near identical mod_rewrite functionality.
The default rewrite rules can be used and the following code inserted to the top of the index.php file:
if (isset($_SERVER['HTTP_X_REWRITE_URL']))
{
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}