Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8177563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:32:25+00:00 2026-06-06T23:32:25+00:00

I ahve apache httpd 2.2.15 (Unix) using mod_rewrite I have this rewrite goingon: RewriteEngine

  • 0

I ahve apache httpd 2.2.15 (Unix) using mod_rewrite

I have this rewrite goingon:

RewriteEngine On
RewriteLogLevel 7
RewriteMap encode-map prg:/var/www/centos6.local/encode.pl
RewriteLog "/var/log/httpd/centos6.local-rewrite_log" 
RewriteCond %{QUERY_STRING} CID=(.*)
RewriteRule .* - [L,CO=NDD_COOKIE:${encode-map:%1}:ndipiazza.test.local:50000]  

The purpose of this is to detect if you find a CID=xyz anywhere in the query string. If you do, create a cookie NDD_COOKIE with xyz encoded by a custom perl script /var/www/centos6.local/encode.pl

This only sets the cookie once, then will not set the cookie again until the server restarts completely.

0) Set hosts file so that ndpiazza.test.local points to 192.168.2.7

1) Launch http://ndipiazza.test.local/test.html?CID=test123

Result: Encoded cookie is written as expected

2) Switch to fresh browser or clear browse cache.

3) Launch http://ndipiazza.test.local/test.html?CID=new567

Result: No cookie is written!

Here is a link to the encode.pl script

Why is this happening?

Here is the rewrite log for http://ndipiazza.test.local/test.html?UID=sfsfsfd888m when it did NOT work:

192.168.2.3 - - [28/Jun/2012:16:33:29 --0500] [ndipiazza.test.local/sid#7fc041c0c880][rid#7fc041d34608/initial] (2) init rewrite engine with requested uri /test.html
192.168.2.3 - - [28/Jun/2012:16:33:29 --0500] [ndipiazza.test.local/sid#7fc041c0c880][rid#7fc041d34608/initial] (3) applying pattern '.*' to uri '/test.html'
192.168.2.3 - - [28/Jun/2012:16:33:29 --0500] [ndipiazza.test.local/sid#7fc041c0c880][rid#7fc041d34608/initial] (4) RewriteCond: input='UID=sfsfsfd888' pattern='UID=(.*)' => matched
192.168.2.3 - - [28/Jun/2012:16:33:29 --0500] [ndipiazza.test.local/sid#7fc041c0c880][rid#7fc041d34608/initial] (5) map lookup OK: map=encode-map key=sfsfsfd888 -> val=
192.168.2.3 - - [28/Jun/2012:16:33:29 --0500] [ndipiazza.test.local/sid#7fc041c0c880][rid#7fc041d34608/initial] (5) setting cookie 'WS_CUID=ndipiazza.test.local; path=/; domain=50000'
192.168.2.3 - - [28/Jun/2012:16:33:29 --0500] [ndipiazza.test.local/sid#7fc041c0c880][rid#7fc041d34608/initial] (1) pass through /test.html
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:32:31+00:00Added an answer on June 6, 2026 at 11:32 pm

    Answer: The system will open the encode.pl only once. It is expected to keep listening for stdin continuously.

    But you can still use prg rewritemap to do this.

    The big thing I was missing is that I needed a while loop in the in perl.

    Here is what I ended up solved the problem with:

    httpd.conf entry:

    RewriteEngine On
    RewriteLogLevel 6
    RewriteLog "/var/log/httpd/centos6.local-rewrite_log" 
    RewriteCond %{QUERY_STRING} UID=(.*)
    RewriteMap encode-map prg:/var/www/centos6.local/encode.pl
    RewriteRule .* - [L,CO=NDD_COOKIE:${encode-map:%1}:ndipiazza.test.local:50000]  
    

    encode.pl:

    #!/usr/bin/perl
    sub trim($) 
    { 
       my $string = shift; 
       $string =~ s/^\s+//; 
       $string =~ s/\s+$//; 
       return $string; 
    } 
        $| = 1; # Turn off I/O buffering    
        while (<STDIN>) {
            s/-/0/g; # Replace dashes with 0's
         $a = $_;    
         $s = '';
         for ($i=0; $i<length($a); ++$i) {
            $c = substr($a, $i, 1);     
                if ($c eq 'Z') { 
                  $s = $s . 'a'; 
               } elsif ($c eq 'z') { 
                  $s = $s . 'A'; 
               } elsif ($c eq '9') { 
               $s = $s . '0'; 
            } else { 
                  $s = $s . chr(ord($c)+1); 
                }
         }
         $s = scalar reverse trim($s);
            print "$s\n";
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im developing a 2d RPG using surfaceview. This is how Ive done: I have
Using fancy box I ahve built a photgallery. When the user clicks on a
I have this written at the very first line on every page of my
I have a xml code that can ahve two forms : Form 1 <?xml
I ahve a html file, in which I include .js file. This file contains
I am sure this should be easy but I ahve been going crazy trying
I ahve this code, the trouble is few of the images are having names,
I ahve this code in asp that has a paragraph and a link in
I am filtering the all list which ahve same lat,long in one list and
i am making a project in which i ahve shedule somthing happen after a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.