0

I have following URL:

myUrl?path=123&param=val

Can you help me to write regular expression which will return path value. i.e

123

at this case?

P.S.

I have REQUEST_URI and QUERY_STRING arguments.

P.S.

more global goal:

rewrite following url:

site.com/cat1/cat2?path=val&param=ololo

to

site.com/cat1/cat2/val

P.P.S

I have read following answer:

https://stackoverflow.com/a/2252242/2674303

but there are a bit another situation.

Community
  • 1
  • 1
gstackoverflow
  • 34,819
  • 98
  • 304
  • 641

1 Answers1

0
RewriteCond %{QUERY_STRING} (.*(?:^|&))path=([^&]*)(.*)
RewriteRule ^/?cat1/cat2$ /cat1/cat2/%2? [PT]

Note, the final '?' drops the old query string.

gstackoverflow
  • 34,819
  • 98
  • 304
  • 641
covener
  • 16,719
  • 2
  • 29
  • 40