I have the rewrite configuration as follows: Code:
RewriteRule ^(.*).p$ /ProductFe?name=$1 [QSA][L]
RewriteRule ^/$ /index.jsp [L]
Khi gõ địa chỉ url http://localhost/ecommerce/a.p =>It worked correctly move to ProductFe http://localhost/ecommerce =>wants to go to the homepage but it still redirects to ProductFe. I don't know where I went wrong please help me
CodePudding user response:
RewriteRule ^(.*).p$ /ProductFe?name=$1 [QSA][L] RewriteRule ^/$ /index.jsp [L]
The second rule rewrites the request to /index.jsp
, but then (during the second pass of the rewrite engine) the first rule rewrites /index.jsp
to /ProductFe?name=/index.j
since /index.jsp
matches the regex ^(.*).p$
(the second dot is not backslash-escaped so matches any character). If the second dot is intended to match a literal dot then it needs to be backslash-escaped. eg. ^(.*)\.p$
The flag argument on the first rule, ie. [QSA][L]
is also incorrectly formatted. This should read [QSA,L]
.
Try the following instead:
RewriteRule ^(. )\.p$ /ProductFe?name=$1 [QSA,END]
RewriteRule ^/$ /index.jsp [END]