Apache 2.2 mod_rewrite question

  • Thread starter Thread starter Paolo Cera
  • Start date Start date
  • Tags Tags
    apache
Click For Summary
SUMMARY

The discussion focuses on the correct syntax for using Apache 2.2's mod_rewrite to check for a substring in a cookie based on the request URI. The user initially attempted to implement a local backreference but faced issues with syntax. The solution involves using the correct backreference notation, specifically \N for capturing groups, which is compliant with POSIX 1003.2+. This clarification aims to prevent similar pitfalls for others working with mod_rewrite rules.

PREREQUISITES
  • Understanding of Apache 2.2 mod_rewrite syntax
  • Familiarity with HTTP cookies and their usage
  • Knowledge of regular expressions and backreferences
  • Awareness of POSIX compliance in operating systems
NEXT STEPS
  • Research Apache 2.2 mod_rewrite directives and their applications
  • Learn about regular expressions in the context of URL rewriting
  • Explore POSIX 1003.2+ compliance and its implications for scripting
  • Investigate advanced cookie handling techniques in Apache
USEFUL FOR

Web developers, system administrators, and anyone implementing URL rewriting with Apache 2.2 who needs to manage cookies effectively.

Paolo Cera
Messages
2
Reaction score
0
Anyone know of the proper syntax that captures this metaphor?

Given a Cookie and URI, I would like to check for the existence of a substring in the cookie in the URI and then proceed to a rewrite rule accordingly.

Here's an example of my reasoning

Code:
RewriteEngine on

...


RewriteCond %{HTTP_COOKIE},%{REQUEST_URI} .*xXx(.+)xXx.*,.*$1.*
RewriteRule blah,blah,blah

I would suspect something likes this is syntactically correct, but repeated testing proves me wrong. Any help would be appreciated.
 
Computer science news on Phys.org
Got the answer to this. Turns out that I'm trying to do something called a local backreference, and the solution is only portable to POSIX 1003.2+ compliant OSes. More on it can be found here.

Note, the bind name /N$ (where 0 < N < 9) did not work for me, but \N did.

Anyways, hope this doesn't trip up anyone else in the future.
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
3K
Replies
26
Views
9K