apache - url address rewriting How to distinguish '? ' question mark
ringa_lee
ringa_lee 2017-05-16 17:04:10
0
1
531

Address: http://localhost/aaa/bbb-ccc=222

RewriteRule ^([a-z,\/,_,0-9]*)-(.*)$ index.php?routeee=$1&$2 [L]

When using '-' to distinguish the address URL, the data can be obtained, '-' is equivalent to a separator

Array ([routeee] => aaa/bbb [ccc] =>222 )

When '-' in the url address is replaced with '? ‘The data cannot be obtained when RewriteRule ^([a-z,\/,_,0-9]*)?(.*)$ index.php?routeee=$1&$2 [L] http://localhost/aaa/bbb?ccc=222

Array ([routeee] => index [_php] => )

RewriteRule ^([a-z,\/,_,0-9]*)?(.*)$ index.php?routeee=$1&$2 [L] How should this rule be written so that it can match normally and obtain the correct data.

\? Escape ‘? 'If there is a question mark, it will not match.

Greatful

But this can be used in nginx

rewrite ^/(.)?(.)$ /index.php?route=$1&$2 last;This rule is normal in nginx.

ringa_lee
ringa_lee

ringa_lee

reply all(1)
淡淡烟草味

apache ignores querystring by default
RewriteRule ^([a-z,/,_,0-9]*)$ index.php?route=$1& [L,QSA]

That’s it. It’s so easy to add querystirng when forcibly executing it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template