Advertisement
Sk8erPeter

web.config for Drupal (6 and 7)

Dec 1st, 2011
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 4.25 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration>
  3.     <system.webServer>
  4.   <!-- Don't show directory listings for URLs which map to a directory. -->
  5.     <directoryBrowse enabled="false" />
  6.  
  7.     <!--
  8.       Caching configuration was not delegated by default. Some hosters may not delegate the caching
  9.       configuration to site owners by default and that may cause errors when users install. Uncomment
  10.       this if you want to and are allowed to enable caching
  11.     -->
  12.     <!--
  13.    <caching>
  14.      <profiles>
  15.        <add extension=".php" policy="DisableCache" kernelCachePolicy="DisableCache" />
  16.        <add extension=".html" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="14:00:00" />
  17.      </profiles>
  18.    </caching>
  19.     -->
  20.  
  21.     <rewrite>
  22.       <rules>
  23.         <!-- rule name="postinst-redirect" stopProcessing="true">
  24.          <match url="." />
  25.          <action type="Rewrite" url="postinst.php"/>
  26.        </rule -->
  27.        
  28.         <rule name="Protect files and directories from prying eyes" stopProcessing="true">
  29.           <match url="\.(engine|inc|info|install|module|profile|test|po|sh|.*sql|postinst.1|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$" />
  30.           <action type="CustomResponse" statusCode="403" subStatusCode="0" statusReason="Forbidden" statusDescription="Access is forbidden." />
  31.         </rule>
  32.    
  33.         <!-- disabling favicon.ico commented.... why do we need it? Server responds 404 if this file doesn't exist... but why do we want to FORCE it?
  34.        <rule name="Force simple error message for requests for non-existent favicon.ico" stopProcessing="true">
  35.          <match url="favicon.ico" />
  36.          <action type="CustomResponse" statusCode="404" subStatusCode="1" statusReason="File Not Found" statusDescription="The requested file favicon.ico was not found" />
  37.        </rule>
  38.         -->
  39.    
  40.     <!-- To redirect all users to access the site WITH the 'www.' prefix,
  41.         http://example.com/... will be redirected to http://www.example.com/...)
  42.         adapt and uncomment the following:    -->
  43.     <!--
  44.        <rule name="Redirect to add www" stopProcessing="true">
  45.          <match url="^(.)$" ignoreCase="false" />
  46.          <conditions>
  47.            <add input="{HTTP_HOST}" pattern="^example.com$" />
  48.          </conditions>
  49.          <action type="Redirect" redirectType="Permanent" url="http://www.example.com/{R:1}" />
  50.        </rule>
  51.        -->
  52.         <!-- To redirect all users to access the site WITHOUT the 'www.' prefix,
  53.                http://www.example.com/... will be redirected to http://example.com/...)
  54.                adapt and uncomment the following:   -->
  55.         <!--
  56.        <rule name="Redirect to remove www" stopProcessing="true">
  57.          <match url="^(.)$" ignoreCase="false" />
  58.          <conditions>
  59.            <add input="{HTTP_HOST}" pattern="^www.example.com$" />
  60.          </conditions>
  61.          <action type="Redirect" redirectType="Permanent" url="http://example.com/{R:1}" />
  62.        </rule>
  63.        -->
  64.  
  65.         <!-- Rewrite URLs of the form 'x' to the form 'index.php?q=x'. -->
  66.         <rule name="Short URLS" stopProcessing="true">
  67.           <match url="^(.*)$" ignoreCase="false" />
  68.           <conditions>
  69.             <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
  70.             <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
  71.             <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
  72.           </conditions>
  73.           <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />
  74.         </rule>
  75.        
  76.         <!-- and there are some other rewrites too, for example for Gallery2 -->
  77.       </rules>
  78.     </rewrite>
  79.  
  80.     <!-- httpErrors>
  81.      <remove statusCode="404" subStatusCode="-1" />
  82.      <error statusCode="404" prefixLanguageFilePath="" path="/index.php" responseMode="ExecuteURL" />
  83.    </httpErrors -->
  84.  
  85.     <defaultDocument>
  86.      <!-- Set the default document -->
  87.       <files>
  88.         <remove value="index.php" />
  89.         <add value="index.php" />
  90.       </files>
  91.     </defaultDocument>
  92.   </system.webServer>
  93. </configuration>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement