Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-08-24
4
Medium Priority
?
177 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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

963 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