I'm wondering if anybody knows a trick to effectively use a back-reference in a match pattern?
Here's an example of what I mean.
- Code: Select all
RewriteEngine on
RewriteMap unescape int:unescape
# Puts a user_id in back-reference %1
RewriteCond ${unescape:%{HTTP_COOKIE}} userid=<(.*)> [NC]
# Puts a report_id in back-reference %2
RewriteCond %{REQUEST_URI} member/reports/(\d+)\.pdf$ [NC]
# Checks if a custom-generated file exists
RewriteCond %{DOCUMENT_ROOT}/members/tagged_reports/%1_%2\.pdf -f [NC]
# Checks if a "report" cookie exists and puts
# a report_id in back-reference %3
RewriteCond %{HTTP_COOKIE} report=(\d+) [NC]
# Now I want to check if a cookie value exists
# with the same value of the report id that's being
# requested --- But I'm not sure how to do this.
# NOTE: I think this doesn't work because %3 isn't a PCRE pattern
RewriteCond %2=%3
# RewriteCond %2 %3
# This rule rewrites the request to a URL that returns a document customized for the user.
RewriteRule ^member/reports/(\d+)\.pdf$ /members/tagged_reports/%1_%2.pdf [NC,L]
Thanks for any suggestions.