shortysbest Posted June 26, 2010 Share Posted June 26, 2010 would there be a way for me to change the url from /index.php?node=home to /index?node=home by using php? like similar to how i change node=home.php to node=home directly in php. I haven't been able to get it to work though. my code for this page handling is: <?php $page = $_GET['node']; if ($page) { //check for section $path = "inc/".$page.".php"; if(file_exists($path)) {include($path);} else {$error = "inc/error.php"; include($error);} } else {$error = "inc/error.php"; include($error);} ?> Quote Link to comment https://forums.phpfreaks.com/topic/205917-url-from-indexphpnodehome-to-indexnodehome-using-php/ Share on other sites More sharing options...
Alex Posted June 26, 2010 Share Posted June 26, 2010 This can't be done in PHP because without a properly formatted URL the request won't even get to the PHP code. Instead you need to look into mod_rewrite. Quote Link to comment https://forums.phpfreaks.com/topic/205917-url-from-indexphpnodehome-to-indexnodehome-using-php/#findComment-1077524 Share on other sites More sharing options...
inversesoft123 Posted June 26, 2010 Share Posted June 26, 2010 Open your .htaccess file and add following lines of code RewriteEngine on RewriteRule ^index?node=$1$ /index.php?node=$1/ [L] I have explained this in thread http://www.phpfreaks.com/forums/index.php/topic,292197.html Quote Link to comment https://forums.phpfreaks.com/topic/205917-url-from-indexphpnodehome-to-indexnodehome-using-php/#findComment-1077529 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.