Solved

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

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

623 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