Pregunta

This is my .htaccess rule:

RewriteRule ^([a-zA-Z0-9\.]+)/([0-9\.]+)/(.*)/(.*)$ m.pl?id=$1&cv=$2&cu=$3&qty=$4

So, a link like cpa/11/axg/4 gets redirected correctly.

But if the 3rd value is blank, i.e.

cpa/11//4, it does not get redirected to the rule defined above.

I am not sure how to address this.

¿Fue útil?

Solución 2

Since the third parameter is optional, solved it as follows:

RewriteRule ^([a-zA-Z0-9\.]+)/([0-9\.]+)/?(.*)/(.*)$ m.pl?id=$1&cv=$2&cu=$3&qty=$4

Otros consejos

You can have 2 separate rules to address this:

RewriteRule ^([a-zA-Z0-9.]+)/([0-9.]+)/([0-9]+)/?$ m.pl?id=$1&cv=$2&qty=$3 [L,QSA]

RewriteRule ^([a-zA-Z0-9.]+)/([0-9.]+)/([^/]+)/([^/]+)/?$ m.pl?id=$1&cv=$2&cu=$3&qty=$4 [L,QSA]
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top