Re: Rewrite query string?

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

 



On Thu, Jan 4, 2024 at 2:53 PM Dave Wreski
<dwreski@xxxxxxxxxxxxxxxxxxx.invalid> wrote:
>
> Hi,
>
> I'm trying to replace "searchword" with just "search" in the following URL:
>
> 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



-- 
Eric Covener
covener@xxxxxxxxx

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx





[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