Tenemos una web con un IIS y el módulo URLRewrite instalado y queremos (esto es un ejemplo) que las urls:
www.mywebsite.com/index.php?section=articles&category=shoesSe reescriban a:
www.mywebsite.com/index.php?section=gallery&galleryType=videos
www.mywebsite.com/articles/shoesCreamos en el web.config de la web las siguientes reglas:
www.mywebsite.com/gallery/videos
Código HTML:
<rewrite> <rules> <rule name="RedirectUserFriendlyURL1" stopProcessing="true"> <match url="^index\.php$" /> <conditions> <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /> <add input="{QUERY_STRING}" pattern="^section=([^=&]+)&category=([^=&]+)$" /> </conditions> <action type="Redirect" url="{C:1}/{C:2}" appendQueryString="false" /> </rule> <rule name="RewriteUserFriendlyURL1" 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?section={R:1}&category={R:2}" /> </rule> <rule name="RedirectUserFriendlyURL2" stopProcessing="true"> <match url="^index\.php$" /> <conditions> <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /> <add input="{QUERY_STRING}" pattern="^section=([^=&]+)&galleryType=([^=&]+)$" /> </conditions> <action type="Redirect" url="{C:1}/{C:2}" appendQueryString="false" /> </rule> <rule name="RewriteUserFriendlyURL2" 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?section={R:1}&galleryType={R:2}" /> </rule> </rules> </rewrite>
www.mywebsite.com/articles/shoes
y todo va bien.
Pero cuando vamos a "www.mywebsite.com/index.php?section=gallery&galleryType=videos" redirige correctamente a:
www.mywebsite.com/gallery/videos
pero la página no funciona.
He mostrado el array $_REQUEST con un var_dump, y en el primer caso muestra:
Código:
Pero en el segundo:REQUEST:
array(2) {
["section"]=>
string(8) "articles"
["category"]=>
string(5) "shoes"
}
Código:
En este caso está cogiendo 'category' en lugar de 'galleryType'. Y por lo tanto, no funciona, ya que en la web usamos las variables GET para hacer las consultas a la base de datos y obtener los contenidos.REQUEST:
array(2) {
["section"]=>
string(7) "gallery"
["category"]=>
string(6) "videos"
}
Imagino que estoy haciendo algo mal o usando un enfoque erróneo.
¿Alguna ayuda por favor?
Gracias por adelantado.
Un saludo.


