Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: From php to perl + template solution

by scorpio17 (Monsignor)
on Jul 13, 2010 at 20:34 UTC ( #849368=note: print w/ replies, xml ) Need Help??


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

I was thinking of something like this:

URL a user enters:

http://your_server/page1.html

mod_perl maps this into:

http://your_server/cgi-bin/myscript.pl?temp=page1.html

or even:

http://your_server/cgi-bin/myscript.pl/page1

(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


Comment on Re^3: From php to perl + template solution
Re^4: From php to perl + template solution
by Nik on Jul 14, 2010 at 06:38 UTC
    Why use mod_perl and not just mod_rewrite with soemthign like this:

    RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^/?(.+) /cgi-bin/index.py?page=$1 [L,PT]
    So every incoming html page request to the web server should redirect to cgi-bin/index.py
    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/index.pl/$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.

        Thank you but for soem reason no matter 2 days now every mod_rewrite rule i try it just seem to NOT work.
        Fro example i try http://webville.gr/index.html to see if it will display the html print or redirect end every time it just display a hello i made. I dont know why.

        I do know though that .htaccess inside document root does get read because if i put random stuff in it and i try the above url it produces an internal server error

        Any clues?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://849368]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2014-08-20 07:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (107 votes), past polls