perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Randolf Richardson" <rand...@modperl.pl>
Subject Re: about request route ($r->path_info)
Date Mon, 07 Aug 2017 16:53:16 GMT
	In your "httpd.conf" file (for your VirtualHost if you're using 
virtual hosts) you'll need to add this line:

		AcceptPathInfo        On

	Then you may find the documentation surrounding $r->path_info to be 
of particular interest, which you can read about here:

		https://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html#C_path_info_

	I use this to implement simple URIs on sites that look like 
"/profile/29862938728" instead of "/profile?id=29862938728" to make 
it easier for users to share links.  Based on your question, it seems 
to me that you're wanting to know how to do something like this.

	Of course, you'll need to write your own Perl code to handle these 
requests, and I suspect that's likely what you're wanting to do.  One 
thing I find very helpful in having done this myself is the use of 
the 404 response code when the data is wrong (e.g., the profile ID 
number does not exist in the database) because then the web server 
just passes everything along to whatever I have configured separately 
for the 404 handler (this is important because it properly 
communicates to search engine spiders and other automated systems 
that the page doesn't exist and should be ignored).

> Hi,
> 
> for this like request:
> curl http://dns-api.org/AAAA/dns-api.org
> 
> in Dancer we could write:
> 
> get '/:type/:domain/?' => sub {
> 
>     my $rtype  = params->{ 'type' };
>     my $domain = params->{ 'domain' };
> 
> 
> But in a MP handler, how could we get the similiar result, treating
> request path as GET/POST arguments?
> thanks.
> 


Randolf Richardson - randolf@inter-corporate.com
Inter-Corporate Computer & Network Services, Inc.
Beautiful British Columbia, Canada
http://www.inter-corporate.com/



Mime
View raw message