Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/07/2015, 04:36
hamramr
 
Fecha de Ingreso: marzo-2007
Mensajes: 59
Antigüedad: 17 años, 1 mes
Puntos: 0
Pregunta IIS URLRewrite Problema variables GET

Buenos días.

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=shoes
www.mywebsite.com/index.php?section=gallery&galleryType=videos
Se reescriban a:
www.mywebsite.com/articles/shoes
www.mywebsite.com/gallery/videos
Creamos en el web.config de la web las siguientes reglas:

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> 
Y cuando vamos a "www.mywebsite.com/index.php?section=articles&category=shoes" redirige a:

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:
REQUEST:
array(2) {
["section"]=>
string(8) "articles"
["category"]=>
string(5) "shoes"
}
Pero en el segundo:

Código:
REQUEST:
array(2) {
["section"]=>
string(7) "gallery"
["category"]=>
string(6) "videos"
}
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.

Imagino que estoy haciendo algo mal o usando un enfoque erróneo.

¿Alguna ayuda por favor?
Gracias por adelantado.
Un saludo.