简体   繁体   中英

IIS web.config to .htaccess

I converted the working web.config file to htaccess.

I am having trouble getting the htaccess file working.

not working htaccess file

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]

working web.config file

<?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>

Turns out that Windows is not case sensitive when handling urls but linux is.

Changing the last rule to include caps worked.

#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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM