netpsycho Posted March 24, 2008 Share Posted March 24, 2008 Ok, I know that the subject was a bit cryptic, but I am completely confused as to where to look for this information (what to search for in google, etc). Anyway, the point is that I am trying to see if I can replicate the method of breaking a php-enabled site into sections the same way that blogs or wikipedia does, by having "fake" subdirectories: This address: http://www.yourblog.com/balloons/ Is in fact: http://www.yourblog.com/index.php/balloons/ (where I am guessing that the "balloons" part is retained via $_GET or the like) Have I gotten it all wrong and they ARE actually subdirectories (in that case, I'd hate to see what some directory trees look like)? I was convinced otherwise when I have seen websites who's address actually looked like the latter example. Also, the gaming blog Giant Bomb uses this for a subcategory: http://www.giantbomb.com/category/arcade/ And the address: http://www.giantbomb.com/index.php/category/arcade/ points to the same place. Is there any way to replicate this? Ps: Please forgive the (potentially) stupid question, it's just that this has bugged me for a while. Quote Link to comment https://forums.phpfreaks.com/topic/97683-getting-information-from-the-site-address/ Share on other sites More sharing options...
uniflare Posted March 24, 2008 Share Posted March 24, 2008 you need to use mod_rewrite, google mod rewrite there should be plently of examples , it CAN get quite complicated though. Quote Link to comment https://forums.phpfreaks.com/topic/97683-getting-information-from-the-site-address/#findComment-499831 Share on other sites More sharing options...
wildteen88 Posted March 24, 2008 Share Posted March 24, 2008 One method is to use mod_rewrite which will allow you to create clearn urls like http://www.giantbomb.com/category/arcade/ or you can go the PHP route, example: <?php function get_path() { $path_bits = false; if(isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] != '/') { // get the path info // path format: index.php/module/page/params1/params2/ etc $path = $_SERVER['PATH_INFO']; // check that the last character in the path is not a backslash // if it is we'll remove it if(substr($path, strlen($path)-1, 1) == '/') { $path = substr($path, 0, strlen($path)-1); } // explode the bits from the path, eg module, page and parameters $path_bits = explode('/', $path); // drop index.php array_shift($path_bits); } return $path_bits; } $path_bits = get_path(); echo '<pre>' . print_r($path_bits, true) . '</pre>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/97683-getting-information-from-the-site-address/#findComment-499832 Share on other sites More sharing options...
uniflare Posted March 24, 2008 Share Posted March 24, 2008 i believe the php route is no where near as effective as the mod_rewrite as urls like http://www.giantbomb.com/category/arcade/ will be interpreted by apache before php can deal with it, (as apache calls the scripts requested), so apache will try to find an index in the arcade folder which is in the category folder in the root directory. i would strongly reccomend mod_rewrite if you are serious about clean/reliable url redirects/formats. Quote Link to comment https://forums.phpfreaks.com/topic/97683-getting-information-from-the-site-address/#findComment-499835 Share on other sites More sharing options...
wildteen88 Posted March 24, 2008 Share Posted March 24, 2008 i believe the php route is no where near as effective as the mod_rewrite as urls like http://www.giantbomb.com/category/arcade/ will be interpreted by apache before php can deal with it, (as apache calls the scripts requested), so apache will try to find an index in the arcade folder which is in the category folder in the root directory. i would strongly reccomend mod_rewrite if you are serious about clean/reliable url redirects/formats. The only difference is index.php has to be present in the url, it is still as effective as mod_rewrite. Quote Link to comment https://forums.phpfreaks.com/topic/97683-getting-information-from-the-site-address/#findComment-499836 Share on other sites More sharing options...
netpsycho Posted March 24, 2008 Author Share Posted March 24, 2008 Wow, you guys are fast! I went out to the store to fetch some food and by the time I got back there were two answers waiting for me. I will look into both. Thank you very much! Quote Link to comment https://forums.phpfreaks.com/topic/97683-getting-information-from-the-site-address/#findComment-499844 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.