Difference between revisions of "Enabling Search Engine Friendly (SEF) URLs on IIS/IIS7"

From Joomla! Documentation

< Enabling Search Engine Friendly (SEF) URLs on IIS
(Add translation tags)
(Several markup changes. URL correction.)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 
<noinclude><languages /></noinclude>
 
<noinclude><languages /></noinclude>
 
<translate><!--T:1-->
 
<translate><!--T:1-->
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.</translate>
+
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.</translate>
  
 
<translate><!--T:2-->
 
<translate><!--T:2-->
You can create the file yourself or use the GUI in the IIS7 Manager. You can import .htaccess rules using the GUI/wizard.</translate>
+
You can create the file yourself or use the GUI in the IIS7 Manager. You can import ''.htaccess'' rules using the GUI/wizard.</translate>
  
 
<translate><!--T:3-->
 
<translate><!--T:3-->
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.</translate>
+
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.</translate>
  
<translate><!--T:4-->
+
<translate>
===GUI===</translate>
+
===GUI=== <!--T:4--></translate>
 
<translate><!--T:5-->
 
<translate><!--T:5-->
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.</translate>
+
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.</translate>
  
 
<translate><!--T:6-->
 
<translate><!--T:6-->
In the Joomla config turn on both the SEF and Apache mod_rewrite, next create a rule under IIS URL Rewrite:</translate>
+
In the Joomla config turn on both the SEF and Apache ''mod_rewrite''. Next create a rule under IIS URL Rewrite:</translate>
 
:Pattern field: '''^([^/]+)/?$'''
 
:Pattern field: '''^([^/]+)/?$'''
:Ignore case '''ON'''
+
:Ignore case ''ON''
:Action type: '''Rewrite'''
+
:Action type: ''Rewrite''
:Rewrite URL: '''index.php/'''
+
:Rewrite URL: ''index.php/''
  
<translate><!--T:7-->
+
<translate>=== ''web.config'' === <!--T:7--></translate>
===web.config===</translate>
 
 
<translate><!--T:8-->
 
<translate><!--T:8-->
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/</translate>
+
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'', see [https://learn.microsoft.com/en-us/iis/application-frameworks/install-and-configure-php-applications-on-iis/translate-htaccess-content-to-iis-webconfig Translate ''.htaccess'' Content to IIS ''web.config'']</translate>
  
<source lang="xml">
+
<syntaxhighlight lang="xml">
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<configuration>
 
<configuration>
Line 69: Line 68:
 
     </system.webServer>
 
     </system.webServer>
 
</configuration>
 
</configuration>
 +
</syntaxhighlight>
  
</source>
 
 
<noinclude>
 
<noinclude>
 
[[Category:IIS]]
 
[[Category:IIS]]
 
[[Category:Search Engine Friendly URLs]]
 
[[Category:Search Engine Friendly URLs]]
 
</noinclude>
 
</noinclude>

Latest revision as of 13:25, 7 November 2022

Other languages:
English • ‎français • ‎português do Brasil

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[edit]

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[edit]

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, see Translate .htaccess Content to IIS web.config

<?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="(\&lt;|%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&amp;view=article&amp;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>