ohdang888 Posted September 9, 2008 Share Posted September 9, 2008 ok so sometimes on sites you see this: http://www.mywebsite.com/blog/234522/This-is-a-blog-about-blogs so the blog id is 234522, and the title is This-is-a-blog-about-blogs so instead of looking for the 234522 folder, it has it set so it won't go to the folder, but rather the "blog" folder, then grabs the info from the url... i know this can be done like id=234526&title=this is the title but how do you do it that other way??? Thanks. Link to comment https://forums.phpfreaks.com/topic/123350-grab-info-from-url/ Share on other sites More sharing options...
DarkWater Posted September 9, 2008 Share Posted September 9, 2008 mod_rewrite Link to comment https://forums.phpfreaks.com/topic/123350-grab-info-from-url/#findComment-637082 Share on other sites More sharing options...
kevinak Posted September 9, 2008 Share Posted September 9, 2008 Ok, I had this brilliant idea a little while back. But I have a bad feeling that using mod_rewrite is a lot safer. function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } $whatever_ID = curPageURL(); $whatever_ID2 = explode('/',$whatever_ID); Basically you store the url into an array with that function. Then you simply explode that array and pull the data from it. Link to comment https://forums.phpfreaks.com/topic/123350-grab-info-from-url/#findComment-637096 Share on other sites More sharing options...
DarkWater Posted September 9, 2008 Share Posted September 9, 2008 mod_rewrite is faster, easier, (probably) safer, and just works better. Link to comment https://forums.phpfreaks.com/topic/123350-grab-info-from-url/#findComment-637103 Share on other sites More sharing options...
kevinak Posted September 9, 2008 Share Posted September 9, 2008 I'm going to agree with this, seriously. But do you have a link to a place with a good mod_rewrite tutorial? Link to comment https://forums.phpfreaks.com/topic/123350-grab-info-from-url/#findComment-637119 Share on other sites More sharing options...
DarkWater Posted September 9, 2008 Share Posted September 9, 2008 It's just regular expressions... Link to comment https://forums.phpfreaks.com/topic/123350-grab-info-from-url/#findComment-637126 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.