On Thu, Jan 4, 2024 at 2:53 PM Dave Wreski
<dwre...@guardiandigital.com.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
cove...@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org

Reply via email to