Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Do you hide .pl extension on web pages?

by punch_card_don (Curate)
on Jan 23, 2013 at 16:09 UTC ( [id://1014942]=perlquestion: print w/replies, xml ) Need Help??

punch_card_don has asked for the wisdom of the Perl Monks concerning the following question:

Motley Monks,

If you're using a Perl templating system to serve web pages, the url displayed in the browser is often going to look something like

http://www.mysite.com/cgi-bin/my_templating_script.pl?page=thepage
How many people care enough about displaying cleaner urls to bother doing anything about this? And if you do, what do you do?

Thanks.




Time flies like an arrow. Fruit flies like a banana.

Replies are listed 'Best First'.
Re: Do you hide .pl extension on web pages?
by MidLifeXis (Monsignor) on Jan 23, 2013 at 16:36 UTC

    I tend to abstract the endpoint, named as what I want it to do, not named as what does it. I also use mod_rewrite for applications not able to handle the rewrite within (vendor CGI, for example).

    Allows me to do things like http://example.com/api/parts/ instead of http://example.com/vendor_endpoint/getAllParts.cgi.....

    If our vendor changes, their implementation changes, they have a hardcoded endpoint (.../cgi-bin/..., for example), or we add a layer in front of the vendor's implementation (say for another parts database), I am able to add that into the system without the client application (or the user) knowing the difference. It does require some planning and maintenance on your endpoints. I use it because it isolates our API from the implementation of our API.

    --MidLifeXis

Re: Do you hide .pl extension on web pages?
by choroba (Cardinal) on Jan 23, 2013 at 16:19 UTC
    Use Dancer and your url can be something like
    http://www.mysite.com/question/q4
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      Right. I use Perl Catalyst and this isn't an issue. Using an MVC for your web application is definitely the way to go. I was a die-hard CGI guy for several years, but after having used a real MVC web application framework, I wouldn't do it any other way. The scalability is mind-blowing.

      Tommy
      A mistake can be valuable or costly, depending on how faithfully you pursue correction
        Die-hard CGI guy - yes, that's it. But, after suffering the indignity of having my example called "a really old school URL", I'm thinking it's time to join the 2010's.

        I've been reading about Dancer today. What's not clear to me is - it's a module you download from CPAN an install, but it sounds like a server, for example "listening" on a port. The intro slides on the Dancer website offer this seemingly oxymoronic explanation: "A Dancer script is a webserver."

        Script or webserver?

        Anyone?

        Thanks.




        Time flies like an arrow. Fruit flies like a banana.
Re: Do you hide .pl extension on web pages?
by suaveant (Parson) on Jan 23, 2013 at 16:32 UTC
    Are you in Linux? I'm not sure about Windows but certainly in Apache under Linux if you specify a directory as a script directory you don't need any extension, or can use whatever. The script just needs to be executable with the shebang.

    That being said almost nothing of ours actually runs Perl as a CGI directly because it is too damn slow that way, our stuff is basically all FastCGI with C cgi accessors.

                    - Ant
                    - Some of my best work - (1 2 3)

Re: Do you hide .pl extension on web pages?
by blue_cowdawg (Monsignor) on Jan 23, 2013 at 16:31 UTC
        How many people care enough about displaying cleaner urls to bother doing anything about this? And if you do, what do you do?

    Myself the idea of hiding a ".pl" extension on a URL gets a non-committal "meh."

    If I were really interested in doing that I supposed I could symlink to a filename devoid of the .pl but that might not work depending on how the server is configured. (I'll have to try that later.)

    I see plenty of other examples of "unclean URLs" such as the Wall Street Journal's website and others...


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
Re: Do you hide .pl extension on web pages?
by CountZero (Bishop) on Jan 23, 2013 at 18:42 UTC
    Yes that is a really "old school" URL, but actually who cares? Nobody is ever going to have to type that URL in the address bar of the browser. All you need is an easy URL to the first page and then it is just all clicking on links.

    Half of my colleagues in the office don't even know what an URL is and never use the address bar: they just type the URL in the Google search box and then click their way to the site.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
Re: Do you hide .pl extension on web pages?
by Melly (Chaplain) on Jan 23, 2013 at 16:40 UTC

    Wouldn't using a mod_rewrite in apache be the way to go with this?

    That said, I know you can use it to redirect foo to foo.php, but I'm not sure if you can use it to hide .php

    ... or maybe you can? Take a look at: http://stackoverflow.com/questions/1992183/how-to-hide-the-html-extension-with-apache-mod-rewrite

    map{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e**2 -$d**2+$b);$c=$d**2+$e**2>4?$d=8:_}1..50;print$c}0..59;print$/}0..20
    Tom Melly, pm (at) cursingmaggot (stop) co (stop) uk

      If you do a rewrite of the URL (the [R] option), it will be shown to the client.

      If you proxy them ([P]), it won't.

      However, you could also use mod_negotiation's Multiviews so that when a URL comes in, it'll look for files with an extension if there isn't an extensionless version. The problem comes when you have both 'foo.php' and 'foo.pl' or 'foo.cgi', you might not have what you expected being served (without some extra effort to set the priorities)

Re: Do you hide .pl extension on web pages?
by tobyink (Canon) on Jan 23, 2013 at 17:45 UTC

    I generally use something like mod_rewrite.

    Yes, I consider this an important thing to do, as it gives me the freedom to restructure the internals of the site without changing any of the public URLs.

    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
Re: Do you hide .pl extension on web pages?
by davido (Cardinal) on Jan 23, 2013 at 18:10 UTC

    I don't need to hide it; I use Mojolicious (official website). Mojolicious routes are fantastic (though they can be a little confusing at first, particularly if you need things like bridges).


    Dave

Re: Do you hide .pl extension on web pages?
by DrHyde (Prior) on Jan 24, 2013 at 12:06 UTC
    I don't care what my URLs look like, but for new code I'm generally using Dancer these days so they look all shiny and modern anyway without me having to get angry at mod_rewrite.
Re: Do you hide .pl extension on web pages?
by sundialsvc4 (Abbot) on Jan 23, 2013 at 19:53 UTC
    Customarily, yes, I do.
Re: Do you hide .pl extension on web pages?
by Anonymous Monk on Jan 24, 2013 at 01:19 UTC

    your web server is responsible for that url, so use whatever you like

    CGI::Emulate::PSGI if you want to Plack it up and customize

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1014942]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-24 08:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found