HTTP_COOKIE problem
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > HTTP_COOKIE problem




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    HTTP_COOKIE problem  
manoj.agarwal.in@gmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-21-06 12:50 PM

Hi

I want to do some hash on the HTTP_COOKIE string which gives me a value
between 1 to 1000. For this I have written a PERL script. Now I want to
call this PERL script in my rewrite.conf (rewrite rule file) file in
apache. I am using RewriteMap for this but haven't succeeded. May be I
haven't understood using rewritemap well.
So my question is:

a. Can I reset my HTTP_COOKIE value in the rewrite.conf file?
b. Would calling a PERL script be a good idea for this or is there any
other way around?
c. Can I write the logic of hashing within my conf file?


My conf file looks like:

RewriteMap  cookie1 prg:/home/y/share/htdocs/cookie1.pl
RewriteRule ^/(index.html)?$ ${bcookie:$1} [L,PT]

Am I doing something wrong in this?

rgds
Manoj






[ Post a follow-up to this message ]



    Re: HTTP_COOKIE problem  
Duikboot


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-21-06 12:50 PM

I am not sure, but shouldn't the rewrite rules be in a .htaccess file or
in the httpd.conf?

greetings,

Duikboot


manoj.agarwal.in@gmail.com wrote:
> Hi
>
> I want to do some hash on the HTTP_COOKIE string which gives me a value
> between 1 to 1000. For this I have written a PERL script. Now I want to
> call this PERL script in my rewrite.conf (rewrite rule file) file in
> apache. I am using RewriteMap for this but haven't succeeded. May be I
> haven't understood using rewritemap well.
> So my question is:
>
> a. Can I reset my HTTP_COOKIE value in the rewrite.conf file?
> b. Would calling a PERL script be a good idea for this or is there any
> other way around?
> c. Can I write the logic of hashing within my conf file?
>
>
> My conf file looks like:
>
> RewriteMap  cookie1 prg:/home/y/share/htdocs/cookie1.pl
> RewriteRule ^/(index.html)?$ ${bcookie:$1} [L,PT]
>
> Am I doing something wrong in this?
>
> rgds
> Manoj
>





[ Post a follow-up to this message ]



    Re: HTTP_COOKIE problem  
Robert Ionescu


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-21-06 10:56 PM

Duikboot wrote:
> I am not sure, but shouldn't the rewrite rules be in a .htaccess file or
> in the httpd.conf?

httpd.conf should be always preferred for a better performance because
the RegEx is only compiled once at startup and not per each processing
of the .htaccess file. A RewriteMap cannot be defined in per-dir
context, so the directive must be placed in per-server context (main
server config section or virtualhost).

-> Avoid .htaccess files, if possible.

--
Robert





[ Post a follow-up to this message ]



    Re: HTTP_COOKIE problem  
Robert Ionescu


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-21-06 10:56 PM

manoj.agarwal.in@gmail.com wrote:
> a. Can I reset my HTTP_COOKIE value in the rewrite.conf file?

Some environmental variables (i.e. document_root) cannot be changed via
the E-Flag or mod_setenv(if).

The RewriteMap only returns a value which is being insert here in the
substitution. I don't think that you can manipulate ENVs from the prg
lookup script.

The manual states this:
| For each map-function lookup it will receive the key to lookup as a
| newline-terminated string on stdin. It then has to give back the
| looked-up value as a newline-terminated string on stdout

Three options I can think of:
-> You're writing an other int function in mod_rewrite.c from where you
should have access to all apache internals

-> You can try to use the E-flag to set a ENV but as I said, i don't
think that you can override this variable here like

# escape literal periods
RewriteRule ^/(index\.html)?$ - [E=HTTP_COOKIE:${bcookie:$1}]

or if you can't place a map lookup within the E-flag (it's not
documented), I'd use something like

RewriteCond ${bcookie:$1} ^(.*)
RewriteRule ^/(index\.html)?$ - [E=HTTP_COOKIE:%1]

-> You're rewriting to some cgi-script which changes the variables and
then execute a program which returns some output like
exec /usr/bin/php ...somepath...

The difference here is you're in the last step of the processing
(content handler).

> Now I want to call this PERL script in my rewrite.conf (rewrite rule
> file) file in apache.

Make sure that the rules are being executed, i.e. if you're using
virtualhosts, you must place the rules there, or you use
| RewriteEngine on
| RewriteOptions inherit

in your <virtualhost> to include/execute the rules from the main server
config section.

In order to check if the rules are being processed, I'd use a RewriteLog.

--
Robert





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 08:25 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register