IIS web.config到.htaccess

时间:2014-06-03 22:18:16

标签: php .htaccess iis web-config rewrite

我将工作的web.config文件转换为htaccess。

我无法让htaccess文件正常工作。

没有使用htaccess文件

RewriteEngine On
#RULE PRESS RELEASE MOD REWRITE RULE 
RewriteRule ^press-release/([a-z0-9_-]+)$ press-release/index.php?pr=$1 [L]
#RULE IDX MODULE REWRITE RULES SEARCH RESULTS PAGE 
RewriteRule ^idx/homesforsale/([a-z0-9_-]+)$ idx/index.php?tag=$1 [L]
#RULE IDX MODULE REWRITE RULES PROPERTY PROFILE PAGE 
RewriteRule ^idx/([a-z0-9_-]+)-home/([a-z0-9_-]+)-([a-z0-9_-]+)$ idx/index.php?pt=$1&filter=$2&propid=$3 [L]

使用web.config文件

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Press Release Mod Rewrite Rule" stopProcessing="true">
<match url="^press-release/([a-z0-9_-]+)$" /> 
<action type="Rewrite" url="press-release/index.php?pr={R:1}" />
</rule>     
<rule name="IDX Module Rewrite Rules Search Results Page" stopProcessing="true">                
<match url="^idx/homesforsale/([a-z0-9_-]+)$" />             
<action type="Rewrite" url="idx/index.php?tag={R:1}" />
</rule>             
<rule name="IDX Module Rewrite Rules Property Profile Page" stopProcessing="true">              
<match url="^idx/([a-z0-9_-]+)-home/([a-z0-9_-]+)-([a-z0-9_-]+)$" />             
<action type="Rewrite" url="idx/index.php?pt={R:1}&amp;filter={R:2}&amp;propid={R:3}" />
</rule>             
</rules>
</rewrite>
</system.webServer>         
</configuration>

1 个答案:

答案 0 :(得分:0)

事实证明,在处理网址时,Windows不区分大小写,但Linux是。

更改最后一条规则以包括工作上限。

#RULE IDX MODULE REWRITE RULES PROPERTY PROFILE PAGE 
RewriteRule ^idx/([a-zA-Z0-9_-]+)-home/([a-zA-Z0-9_-]+)-([a-zA-Z0-9]+)$ idx/index.php?pt=$1&filter=$2&propid=$3 [L]