Re: Rewrite query string?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



https://example.com/search?searchword=CVE-2021-4014&Search=

I've tried the following RewriteCond/RewriteRule in various forms, but not sure what I'm doing wrong.

RewriteCond %{QUERY_STRING} ^searchword=(.*)
RewriteRule ^   q=$1 [NC,L]

Ideas for what I'm doing wrong would be greatly appreciated.
I think something like this is closer:
RewriteCond %{QUERY_STRING} ^searchword=([^&]+)
RewriteRule ^ %{REQUEST_URI}?search=%1 [NC,L]

- In the cond, I am dropping everything in the query after the CVE
value, since Search= and search= would be confusing together.
- The substitution needs to be the full URL -- using the
%{REQUEST_URI} variable here
- Using a ? in the substitution will replace the existing query
- %1 is the first capture in the preceding condition

This didn't work :-( It found a match, but it doesn't appear to have performed the replacement:

Thu Jan 04 16:41:41.144300 2024] [rewrite:trace4] [pid 510782:tid 510817] mod_rewrite.c(493): [client 68.195.111.42:0] 68.195.111.42 - - [webstage.example.com/sid#55795fe93698][rid#7fa7140322c0/initial]
 RewriteCond: input='searchword=CVE-2021-4014&Search=' pattern='^searchword=([^&]+)' => matched

It even shows the rewrite:

[Thu Jan 04 16:41:41.144316 2024] [rewrite:trace2] [pid 510782:tid 510817] mod_rewrite.c(493): [client 68.195.111.42:0] 68.195.111.42 - - [webstage.example.com/sid#55795fe93698][rid#7fa7140322c0/initial]
 rewrite '/search' -> '/search?search=CVE-2021-4014'

However, this change is not reflected in the Location bar in my browser.

Maybe I'm missing something? Is there any way to enable logging only for the RewriteRule/RewriteCond I'm currently working with, or to otherwise be able to more specifically identify the rule I'm testing?

I'm using:

LogLevel info rewrite:trace5

Thanks,
Dave



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux