Monday 15 July 2013

php - IIS Intermittent Change of Rewrite Settings -



php - IIS Intermittent Change of Rewrite Settings -

i have application build based on codeigniter, , application running on iis7.5 on windows server 2008 r2 standard.

we have 4 separate databases, 1 of each operating state runs on same server. (i know not best practice, have been given work with. not original designer).

so folder construction goes this, , duplicated each state.

wwwroot/ | |-{state}/ |----|index.php //ci index.php |-{state}/ |----|index.php //ci index.php

the state folders windows directories names written in capitals.

each folder has web.config file rewrite uri requests index.php

<?xml version="1.0" encoding="utf-8"?> <configuration> <system.webserver> <httperrors errormode="detailed" /> <asp scripterrorsenttobrowser="true" /> <rewrite> <rules> <rule name="ruleremoveindex" stopprocessing="true"> <match url="^(.*)$" ignorecase="true" /> <conditions> <add input="{request_filename}" matchtype="isfile" negate="true" /> <add input="{request_filename}" matchtype="isdirectory" negate="true" /> </conditions> <action type="rewrite" url="index.php?{r:1}" appendquerystring="true" /> </rule> </rules> </rewrite> </system.webserver> </configuration>

now here confused.

the application times works, , not work depending on weather state component (https://{sub}.{domain}:{port}/{state}/{uri}) written in capitals or not.

when set on server, tested lower case letters {state} , worked fine. came next day, , found using lower case letters give me codeigniter 404 error. if used capital letters {state} work find. , alter around 1 time again later.

after doing url rewite testing using same principles here: http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module changed php, noticed

i did url rewrite testing see outcomes of url rewrites were, based on aspx version here: http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module changed php. found $_server['script_name'] retaining first way in the {state} beingness type (capital or lower case). temporary prepare sure bad practice, added script start of index.php file

$_script_name = $_server['script_name']; $_script_name_array = explode('/', $_script_name); $_script_name_array[1] = strtolower($_script_name_array[1]); $_script_name = implode('/', $_script_name_array); $_server['script_name']=$_script_name;

which has half fixed issue, forces utilize of states in lower case. nice if solution found doesn't matter if {state} written in capitals or not.

i hoping on here might have idea's.

iis rewrite handy in case

add next code web.config file located in root of web folder.

<rule name="lowercaserule" stopprocessing="true"> <match url="[a-z]" ignorecase="false" /> <action type="redirect" url="{tolower:{url}}" /> </rule>

here url rewrite can find more details on it. hope help you.

php codeigniter mod-rewrite iis http-status-code-404

No comments:

Post a Comment