Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^2: From php to perl + template solution

by Nik
on Jul 13, 2010 at 16:26 UTC ( #849313=note: print w/replies, xml ) Need Help??

in reply to Re: From php to perl + template solution
in thread From php to perl + template solution

Thanks. Can't i just use mod_rewrite telling the webserver NOT TO run html pages the user clicks because these are my actual templates waiting to be rendered and instead redirect those requests to script to calculate the counter data, render the tempalte and display it?
  • Comment on Re^2: From php to perl + template solution

Replies are listed 'Best First'.
Re^3: From php to perl + template solution
by scorpio17 (Abbot) on Jul 13, 2010 at 20:34 UTC

    I was thinking of something like this:

    URL a user enters:


    mod_perl maps this into:


    or even:


    (this is how it will look if you use CGI::Application. I suggest get this working first, then add a .htaccess file in your cgi-bin directory to add the mod_perl mod_rewrite stuff afterwords.)

    The script reads in template "page1.html", figures out the counter value, inserts it, and displays the page.

    All the template files should be in a special directory, not under the document root, so there's no way a user can point their browser to the "real" page1.html.

    update: corrected typo

      Why use mod_perl and not just mod_rewrite with soemthign like this:

      RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^/?(.+) /cgi-bin/$1 [L,PT]
      So every incoming html page request to the web server should redirect to cgi-bin/
      Isn't it more easy?

      My rule although seems correct thought aint working because when a request an html page a get its output instead of redirection
        oops - that was a typo. I meant "mod_rewrite", not "mod_perl".

        I'd try something like this (untested):

        # skip rule if item is an actual file or directory # (like images or stylesheets) RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^(.*)/?$ /cgi-bin/$1 [L,QSA]

        Your script can get the $1 parameter from $ENV{PATH_INFO}, and use that to determine which template file to use, etc.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://849313]
[erix]: oh, I see... it's pretty obvious really
[choroba]: What do you mean by "anchors"?
[erix]: anchors
[erix]: I have figured it out. I actually constructed them correctly but used a faulty url *headdesk*
[erix]: ( you use anchors to jump to via a #-suffix to the url -- I am sure you know )

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2018-06-19 12:41 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (113 votes). Check out past polls.