Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How set rule in .htaccess when argument=argument?

For example:

RewriteCond %{QUERY_STRING} (?)argument=argument

but:

RewriteCond %{QUERY_STRING} (?)argumentext=argumentext

I find rule:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

RewriteCond %{QUERY_STRING} (?)[a-zA-Z0-9_]=[a-zA-Z0-9_]

But this rule find only "=" and random text before and after, but i need when argument=value

Example:

IP - - [DATE] "GET /?value=value HTTP/1.1" 
IP - - [DATE] "GET /?random=random HTTP/1.1" 
IP - - [DATE] "GET /?qwerty=qwerty HTTP/1.1" 
IP - - [DATE] "GET /?randomvalues=randomvalues HTTP/1.1" 

Need a rule when they are equal

>Solution :

You can use this rule with a capture group and a back-reference:

RewriteCond %{QUERY_STRING} ^([^=]+)=\1$
RewriteRule ^ - [G]

Here RewriteRule ^ - [G] is used for testing only.

Explanation:

  • ^: Match start
  • ([^=]+): Match 1+ of any character that is not = in capture group #1
  • =: Match a =
  • \1: Match same value as in capture group #1
  • $: End
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading