Solved

Can I use mod_rewrite to do two things instead of one?

Posted on 2004-08-24
4
169 Views
Last Modified: 2010-03-04
I want to use mod_rewrite to
          1.  write enviromental vars to a DB (in background)
          2.  go to the requested page

Can this be done?  I know that this can be done with PGP and auto_prepend_file, but can this be done without PHP?

Thanks!
0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
brozzis earned 500 total points
ID: 11891936

write in a DB thru mod_rewrite ? hopefully not.

this can be quite trivially accomplished thru a PHP/perl/shell/whatever CGI script,
and mod_rewrite can be used successfully to implement a system to redirect to your cgi script
that should redirect you to your final page.

If you are willing to write an apache module to accomplish this, I think this could be done quite easily,
but I can't imagine such an hack to write something in a DB with mod_rewrite...




0
 
LVL 16

Author Comment

by:hankknight
ID: 11898721
Thanks!

If I understand you correctly, you are suggesting two ways to write every request to a DB:

1.  Use mod_rewrite to redirect everything to a script.  The script would write to the database AND send the requested document/file to the browser

2.  Create a custom Apache Mod from scratch

Is this corrrect?
0
 
LVL 2

Expert Comment

by:brozzis
ID: 11900066

Yes.

I don't know your needs, supposed loads, number of daily contacts, etc...
but having a db access for every page request could be a performance problem.
Keeping some session variables (cookies?) and writing just once on a DB per session could be a better choice.

There are already simple apache modules writing logging into mysql and postgreSQL DBs,
you could start from there.
0
 
LVL 16

Author Comment

by:hankknight
ID: 11901233
Thanks!

My logging/traffic stats package uses a DB and requries me to include a line that calls it in every page.
If I want it to log images and other non-dynamic pages, I have to use PHP for ALL file tyles and auto_append a PHP file.

I put the following in httpd.conf or .htaccess:

                ----------------------------------------------------
                ForceType application/x-httpd-php
                php_value auto_append_file "/home/webadmin/domain.com/html/log.php"
                ----------------------------------------------------

               where log.php writes to the DB.

I was hoping that a custom mod would improve performance, since the way I currently do it uses PHP even for images and wtill writes to the DB.

Maybe I should be looking for a logging script that doesn't use a Database.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question