Forum Moderators: phranque

Message Too Old, No Replies

Converting to Static Content using Perl

Little confused on URI construction

         

lgn1

3:57 pm on Oct 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I read an article about using path_info and URI rewriting in perl to obtain static like content, however im a little confused.

I have been told to change from the form

www.widget.com/cgi-bin/script.pl?cart_id=whatever&page=whateverelse to the form

www.widget.com/cgi-bin/script/cart_id/whatever/page/whateverelse

like amazon.com does and use the PATH_INFO to break out the variables using / delimiter.

This make sense except for one thing:

How does server now to execute the script rather than search for the subdirectory whateverelse as all the dilimeters are / and the? is gone.

Birdman

4:57 pm on Oct 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there,

In all the examples of using path info to create nice URLs, the links are in this format:

www.site.com/index.php/cPath/7_63

The URL actually points to a script with an extension and then the vars are added after that. I don't particularly like that method, but it does seem to work.

My preferred method is to use Apache mod_rewrite to silently redirect the request. This way you don't even need to parse the path info in the script. Mod_rewrite puts the vars in the querystring and then you can access them the 'normal' way.

Check the Apache forum for ALOT of examples.

Regards,
Birdman

lgn1

6:33 pm on Oct 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Our ISP uses IIS and will not allow a mod_rewrite third party application, so im stuck with the method above.

So what you are saying is the URI is parsed from left to right, and once it encounters the script name, it will immediatly execute the script, and it will pull the remainder of the URI (the fake directory look alike) into the variables in my script (by using QUERY_STRING and PATH_INFO and a bit of string manipulation).

Cool

lgn1

12:28 am on Oct 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is their something that needs to be done on a server, as it is not working.

I even tried using the simple hello.pl script and

www.widget.com/cgi-bin/hello.pl/cartid/cart_no/pageid/pageno

brings up page not found (as it is treating this like a directory path instead of passing the data after hello.pl to the script.

To get the hello script to work I need to put the? after hello.pl, and im trying to avoid the special characters to make the site spider friendly.

Will this work in Appache and not in IIS. Have anybody tried this on IIS

lgn1

4:50 pm on Nov 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



After looking at the Apache forum it appears that this technique must be used in conjunction with mod_rewrite,
as mod_rewrite will capture the URI and convert it to the directory_path?query string form using the mod_rewrite rules.

Since im on IIS and my ISP is unwilling to install a third party mod_rewrite script, im stuck.

ddent

5:49 pm on Nov 1, 2004 (gmt 0)

10+ Year Member



There are equivalents for IIS, so you could ask them to do that for you.

But then again, if you are having trouble doing things you want to do to improve your site merely because of your ISP, maybe the problem is not you but rather your ISP?