2012-12-11 21 views
2

我發現在我的服務器(_SERVER [「SERVER_SOFTWARE」] -Microsoft-IIS/7.0),架構x86上未啓用mod_rewrite函數。如何啓用mod_rewrite.Could任何一個請幫幫我。如何在iis服務器上啓用mod_rewrite

+0

它是否在php.ini文件中啓用? – tuespetre

+0

我編輯了我的服務器上的php.ini文件嗎? – rms

+0

Linux中的/etc/php.ini – tuespetre

回答

0

1)找到的httpd.conf(通常這個文件可以在文件夾callled CONF,配置或沿這些行的東西)

2)找到並取消線的LoadModule rewrite_module模塊/ mod_rewrite.so

發現

3)查找具有的DocumentRoot行「C:/路徑/要/我的/根」,你會發現有類似內容

確保這兩個括號內的內容看起來像

選項所有

的AllowOverride所有

4)現在全部完成重新啓動Apache服務器,你會被大家看好去

+0

在Windows上,apache模塊將具有.dll後綴,在Linux上,您可以在/ etc/httpd /或/ etc/apache2中找到配置 –

2

如果您在一個商業託管服務提供商託管他們很可能有安裝了模塊。這給你類似於Apache mod_rewrite模塊的功能。

要測試此模塊是否已安裝,請在您的網站的根目錄下創建一個名爲web.config的文件,其內容如下,並嘗試http://www.domain.com/google,其中domain.com是您網站的域名。如果您被重定向到google.com,您的主機將安裝URL重寫模塊。

的web.config:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
     <rewrite> 
      <rules> 
       <clear /> 
       <rule name="Redirect to google.com" stopProcessing="true"> 
        <match url="^google$" /> 
        <action type="Redirect" url="http://www.google.com/" appendQueryString="false" /> 
       </rule> 
      </rules> 
     </rewrite> 
    </system.webServer> 
</configuration> 
2

爲我工作的答案是安裝Microsoft URL Rewrite模塊,然後在它(規則)創建的網站的根web.config文件與此:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
    <rewrite> 
     <rules> 
     <rule name="Security Rule" stopProcessing="true"> 
      <match url="^(.*)$" ignoreCase="false" /> 
      <conditions logicalGrouping="MatchAny"> 
      <add input="{QUERY_STRING}" pattern="mosConfig_[a-zA-Z_]{1,21}(=|\%3D)" ignoreCase="false" /> 
      <add input="{QUERY_STRING}" pattern="base64_encode.*\(.*\)" ignoreCase="false" /> 
      <add input="{QUERY_STRING}" pattern="(\&lt;|%3C).*script.*(\>|%3E)" /> 
      <add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" /> 
      <add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" /> 
      </conditions> 
      <action type="CustomResponse" url="index.php" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" /> 
     </rule> 
     <rule name="SEO Rule"> 
      <match url="(.*)" ignoreCase="false" /> 
      <conditions logicalGrouping="MatchAll"> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" /> 
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" pattern="" ignoreCase="false" /> 
      <add input="{URL}" negate="true" pattern="^/index.php" ignoreCase="false" /> 
      <add input="{URL}" pattern="(/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$" /> 
      </conditions> 
      <action type="Rewrite" url="index.php" /> 
     </rule> 
     </rules> 
    </rewrite> 
</system.webServer> 
</configuration> 
相關問題