Solved

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

Posted on 2004-08-24
4
165 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
  • 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now