2014-01-09 50 views
1

我主要使用Apache和.htaccess,但我目前正在使用托管在Windows服务器上的网站。 Web.config导致了很多问题。Web.config将所有路径重定向到index.php - 不起作用

我试图将所有URL请求重定向到index.php,以便PHP脚本可以解析URL并提供正确的页面。

的的.htaccess(这在Apache正常工作)如下:

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^(.*)$ - [NC,L] 
RewriteRule ^(.*)$ /index.php [NC,L] 

在Web.config重写(不想要的工作):

<rewrite> 
     <rules> 
      <rule name="rule 1G" stopProcessing="false"> 
       <match url="^(.*)$" ignoreCase="true" /> 
       <action type="Rewrite" url="/-" /> 
      </rule> 
      <rule name="rule 2G" stopProcessing="false"> 
       <match url="^(.*)$" ignoreCase="true" /> 
       <action type="Rewrite" url="//index.php" /> 
      </rule> 
     </rules> 
    </rewrite> 

这里是我的Apache测试服务器上的网站:http://villasilvana.hotmintmedia.com 而在这里的Windows服务器上:http://www.villasilvana.net(更新 - 我不得不恢复到原来的生活网站,因为它仍在使用中)

我已经浏览了ISS和Web.config上的无数页面,并在重写代码上尝试了许多变体,其中没有任何变化。我将不胜感激任何帮助。

回答

4

我知道这是一个有点晚了一天,但如果其他人正在寻找

<!--web.config url rewrite--> 
<configuration> 
    <system.webServer> 
     <rewrite> 
      <rules> 
       <rule name="Redirect To Index" stopProcessing="true"> 
        <match url=".*" /> 
        <conditions> 
         <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> 
    </system.webServer> 
</configuration> 
+0

此,如果你有'在URL%2B'不起作用。这打破了我的注册网址,因为它们在url中包含密码。 – Ciantic

相关问题