문제

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.

도움이 되었습니까?

해결책 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

다른 팁

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]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top