AnimeSuki Forums

Register Forum Rules FAQ Community Today's Posts Search

Go Back   AnimeSuki Forum > Support > Forum & Site Feedback

Notices

Reply
 
Thread Tools
Old 2004-06-29, 19:19   Link #1
Dark Morford
Junior Member
*Fansubber
 
 
Join Date: Jun 2004
Location: Redmond, WA
Age: 40
Send a message via ICQ to Dark Morford Send a message via AIM to Dark Morford Send a message via MSN to Dark Morford
Question /file.html after .php?

I notice that AnimeSuki uses URLs with slashes and filenames after a PHP filename (ex. http://www.animesuki.com/group.php/00.html). This has me both confused and interested, because I'm used to seeing URLs with standard GET systax (ex. http://www.example.com/group.php?group_id=00). I assume that the pseudo-directory syntax has some advantage over the GET syntax, else AnimeSuki would not use it.
I would like to know what advantage directory syntax has over GET syntax, and also how to implement it in my own pages (example code much appreciated). Apologies in advance if this is in the wrong forum.
Dark Morford is offline   Reply With Quote
Old 2004-06-30, 00:48   Link #2
Lefteris_D
Senior Member
 
 
Join Date: Apr 2001
Location: Athens, Greece
Age: 41
Quote:
Originally Posted by Dark Morford
I would like to know what advantage directory syntax has over GET syntax, and also how to implement it in my own pages (example code much appreciated). Apologies in advance if this is in the wrong forum.
I find it to be more search engine friendly

Anyway, what you need is $HTTP_SERVER_VARS["PATH_INFO"].

Create a file called test.php and put this code in[PHP]<?
echo $HTTP_SERVER_VARS["PATH_INFO"];
?>[/PHP]

Now call your script with a random syntax http://www.mysite.com/test.php/page.html

The result will be a print that says "/page.html", now you can use the content of the $HTTP_SERVER_VARS["PATH_INFO"] variable for anything you want.

As for encoding more than one variables in the path... I'm not there yet
__________________
...
Lefteris_D is offline   Reply With Quote
Old 2004-06-30, 12:42   Link #3
NightWish
…Nothing More
*Administrator
 
 
Join Date: Mar 2003
Age: 44
As Lefteris_D said, the server variable "path_info" is often used to improve search engine compatibility. Until recently very few search engines supported trawling web documents that could only be accessed via links that passed information in the "query_string"; a notable exception to this being Google.

This meant that pages using information after the "?" in the URL would not be seen and would hence not be indexed by the spider. That or they would be requested without the query information; resulting in a "default" page view regardless of context or possibly just meaningless errors -- all of which would just "poison" the search engines database. Using the path_info you get around this by passing the required information in the already supported "path" component of the URL.

It is also considered more esthetically pleasing; "viewdoc/100.html" looks nicer and is often easier to remember than "viewdoc.php?document_id=100". This becomes even more powerful when you have lots of other variables.

For example; on this forum a url like:
http://forums.animesuki.com/showthread.php?t=12345&page=5
Could look much better as:
http://forums.animesuki.com/showthread/12345/5.htm
Note: You don't need the ".php" if the server is configured "correctly".
If the software supported it...

Once you're aware of it you'll notice it on many more sites; like Amazom for example. They often put session id information in the URL in such a way that all the links on the page "auto-magically" pick up the session id, thus maintaining the session even if you don't have cookies enabled. I believe a lot of JSP applications do the same.

P.S. If you are using a version of PHP greater than 4.1.0 (which you really should be by now) you don't want to use the "$HTTP_SERVER_VARS" at all, you want to use the super-global "$_SERVER" instead; as the former is deprecated .

Last edited by NightWish; 2004-06-30 at 12:59. Reason: Added PS.
NightWish is offline   Reply With Quote
Old 2004-06-30, 12:57   Link #4
Lefteris_D
Senior Member
 
 
Join Date: Apr 2001
Location: Athens, Greece
Age: 41
Quote:
Originally Posted by NightWish
P.S. If you are using a version of PHP greater than 4.1.0 (which you really should be by now) you don't want to use the "$HTTP_SERVER_VARS" at all, you want to use the super-global "$_SERVER" instead; as the former is deprecated .
Given the fact that all $HTTP_SERVER_VARS variables are disabled by default in php5(recommended php.ini) as well then yes, $_SERVER is a must for future compatibility

Note: $HTTP_SERVER_VARS can be used in php5 if enabled much like Register Globals though it is not recommended.
__________________
...
Lefteris_D is offline   Reply With Quote
Old 2004-06-30, 13:02   Link #5
NightWish
…Nothing More
*Administrator
 
 
Join Date: Mar 2003
Age: 44
Oh and you can encode as much as you like into the path, so long as you use valid URL characters...

[PHP]<?php
$params = explode( '/', $_SERVER['PATH_INFO'] );
print_r( $params );
?>[/PHP]
Spoiler for Output using url example from previous post...:
NightWish is offline   Reply With Quote
Old 2004-06-30, 13:13   Link #6
Lefteris_D
Senior Member
 
 
Join Date: Apr 2001
Location: Athens, Greece
Age: 41
Yeah, I just realized that $_server['PATH_INFO'] can be handled as an array(stupid me!).

Here is a nice article that features a similar example and a nice .htaccess sample to hide the .php extension

Last edited by Lefteris_D; 2004-06-30 at 13:15. Reason: replaced a few words
Lefteris_D is offline   Reply With Quote
Old 2004-07-01, 15:23   Link #7
GHDpro
Administrator
*Administrator
 
 
Join Date: Jan 2001
Location: Netherlands
Age: 45
Well, pretty much everything has been said already...

For Apache 2.0, make sure you check this page:
http://httpd.apache.org/docs-2.0/mod...acceptpathinfo
GHDpro is offline   Reply With Quote
Old 2004-07-01, 18:50   Link #8
Dark Morford
Junior Member
*Fansubber
 
 
Join Date: Jun 2004
Location: Redmond, WA
Age: 40
Send a message via ICQ to Dark Morford Send a message via AIM to Dark Morford Send a message via MSN to Dark Morford
Thanks for the help, everyone. It makes a lot more sense now.
Dark Morford is offline   Reply With Quote
Old 2004-07-02, 23:02   Link #9
boneyjellyfish
Evangelist of the Kazoo
 
 
Join Date: Apr 2003
Location: AnimeSuki Forums
Quote:
Originally Posted by Lefteris_D
Yeah, I just realized that $_server['PATH_INFO'] can be handled as an array(stupid me!).

Here is a nice article that features a similar example and a nice .htaccess sample to hide the .php extension
Using the ForceType directive is way too much of a hassle for what you really need to do. Instead of that, I'd have to recommend using mod_rewrite. If you know simple regular expressions, you can pretty much customize your URLs however you like. Not only that, but as long as you write PHP with register globals on (that is, not using $_GET, $_POST, etc. to retrieve your variable values), the only thing that you have to change other than your .htaccess file is what your links point to.
boneyjellyfish is offline   Reply With Quote
Old 2004-07-03, 09:57   Link #10
NightWish
…Nothing More
*Administrator
 
 
Join Date: Mar 2003
Age: 44
The use of "register globals" is strongly discouraged for security reasons. You should avoid using it unless there is absolutely no other way to achieve the result you are after...
NightWish is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 03:19.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
We use Silk.