bogdaniel Posted July 16, 2009 Share Posted July 16, 2009 hello i was doing a little google research until i found a website with a tutorial about creating urls without using mod rewrite can someone please explain it to me and give me some example as procedual code and oop? thank you very much for helping me in your spare time. <?php // Get the URL relative to the script $url = $_SERVER['PATH_INFO']; // If for some reason $_SERVER["PATH_INFO"] does not work then // you could use $_SERVER["REQUEST_URI"] or $_SERVER["PHP_SELF"] // Remove the /index.php/ at the beginning $url = preg_replace('/^(\/)/','',$url); // Split URL into array $url = explode('/',$url); // Display array print_r($url); ?> [/[code=php:0] Link to comment https://forums.phpfreaks.com/topic/166181-little-php-help-with-a-code-that-i-dont-understand-quite-well/ Share on other sites More sharing options...
ignace Posted July 16, 2009 Share Posted July 16, 2009 Use this: http://pastebin.com/fc5fee28 This allows you to use url's in the format: http://<domain>/<page>.php[/<module>]/<controller>/<action>/<param1>/<value1> examples: // module = admin // controller = users // action = edit // id = 1 http://localhost/index.php/admin/users/edit/id/1 // module = default // controller = register // action = index http://localhost/index.php/register // module = default // controller = login // action = index http://localhost/index.php/login Link to comment https://forums.phpfreaks.com/topic/166181-little-php-help-with-a-code-that-i-dont-understand-quite-well/#findComment-876351 Share on other sites More sharing options...
bogdaniel Posted July 16, 2009 Author Share Posted July 16, 2009 thank you very much i will have a look on that php file Link to comment https://forums.phpfreaks.com/topic/166181-little-php-help-with-a-code-that-i-dont-understand-quite-well/#findComment-876386 Share on other sites More sharing options...
ignace Posted July 16, 2009 Share Posted July 16, 2009 thank you very much i will have a look on that php file Here's an updated version: http://pastebin.com/f12cbc64c Edit: I tested it and I can confirm it works. If you want I can submit you the used code. P.S. This is the correct format: http://<domain>/<page>.php[/<module>]/<controller>[/<action>[/<param1>/<value1>]] Link to comment https://forums.phpfreaks.com/topic/166181-little-php-help-with-a-code-that-i-dont-understand-quite-well/#findComment-876411 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.