?
Solved

How to funnel all site URLs through a single CGI script?

Posted on 2008-11-14
2
Medium Priority
?
198 Views
Last Modified: 2013-11-05
I'm writi2ng a web application and need all POSTs and GETs to the site to be passed to a single Perl script. I'll be running it on Apache, so I'm really looking for what to add to and/or change in the httpd.conf file.

Sample URLs would include (note the non-extension names):
http://www.xyz.com/
http://www.xyz.com/public/home
http://www.xyz.com/private/dashboard
and I'd like to have the extra paths beyond .com to be passed to the script.

I've been scouring several books and trying different snippets, but now I've really confused myself.

Thanks!
0
Comment
Question by:olevt
2 Comments
 
LVL 27

Accepted Solution

by:
caterham_www earned 500 total points
ID: 22964104
So you're looking for mod_rewrite?

http.conf:
RewriteEngine on
RewriteCopnd %{REQUEST_METHOD} ^(GET|POST)$
RewriteRule ^(/.*)$ /path/to/perl.pl?q=$1 [PT,NS]

That should rewrite any request, except internal subrequests, to your perl script. The QueryString q=... should contain the URL-path.

If you'd like to exclude files (images etc.), the easiest way would be to modify the regular expression so that it doesn't match against URL-paths containing a period:  ^(/[^.]+)$
0
 

Author Closing Comment

by:olevt
ID: 31516913
Thanks, caterham!

By the looks of it, your suggestion appears to be exactly what I need. And your tip about image files was like reading my mind about the future!
0

Featured Post

Technology Partners: 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

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…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month15 days, 18 hours left to enroll

850 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