Script47 Posted July 22, 2013 Posted July 22, 2013 So I was just looking through some stuff and found this site, which cleans up your URL's and gives you mod_rewrite codes. Hope it helps you all. :) http://www.generateit.net/mod-rewrite/ Quote
rjddev Posted July 22, 2013 Posted July 22, 2013 (edited) And for those working withouth htaccess <?php // Example 'dirty' url: http://www.site.com/index.php?page=page&subpage=subpage&id=id // Example 'clean' url: http://www.site.com/index.php/page/subpage/id/ $page = "index.php"; if ( $url = stristr($_SERVER['REQUEST_URI'], 'index.php') ) { // $url == 'index.php/page/subpageid if( $url[strlen($url)-1] == '/') { // Check if the URL ends with a '/' $url[strlen($url)-1] = ''; } $url_segments = explode('/', $url); // $url_segments[0] == 'index.php'; if( isset($url_segments[1]) && $url_segments[1] != '' ) { // If the page in the url is entered, gets $_GET['page'] the value $_GET['page'] = $url_segments[1]; if( isset($url_segments[2]) && $url_segments[2] != ''){ //If the subpage in the url is entered, gets $_GET['subpage'] the value $_GET['subpage'] = $url_segments[2]; if( isset($url_segments[3]) && $url_segments[3] != '') { //if the subpage in the url is entered gets $_GET['subpage'] the value $_GET['subpage'] = $url_segments[3]; } } } } else { $_GET['page'] = $page; } ?> Edited July 22, 2013 by rjddev typo Quote
rockwood Posted July 22, 2013 Posted July 22, 2013 So I was just looking through some stuff and found this site, which cleans up your URL's and gives you mod_rewrite codes. Hope it helps you all. :) http://www.generateit.net/mod-rewrite/ Thanks it is awesome Quote
Script47 Posted July 22, 2013 Author Posted July 22, 2013 And for those working withouth htaccess <?php // Example 'dirty' url: http://www.site.com/index.php?page=page&subpage=subpage&id=id // Example 'clean' url: http://www.site.com/index.php/page/subpage/id/ $page = "index.php"; if ( $url = stristr($_SERVER['REQUEST_URI'], 'index.php') ) { // $url == 'index.php/page/subpageid if( $url[strlen($url)-1] == '/') { // Check if the URL ends with a '/' $url[strlen($url)-1] = ''; } $url_segments = explode('/', $url); // $url_segments[0] == 'index.php'; if( isset($url_segments[1]) && $url_segments[1] != '' ) { // If the page in the url is entered, gets $_GET['page'] the value $_GET['page'] = $url_segments[1]; if( isset($url_segments[2]) && $url_segments[2] != ''){ //If the subpage in the url is entered, gets $_GET['subpage'] the value $_GET['subpage'] = $url_segments[2]; if( isset($url_segments[3]) && $url_segments[3] != '') { //if the subpage in the url is entered gets $_GET['subpage'] the value $_GET['subpage'] = $url_segments[3]; } } } } else { $_GET['page'] = $page; } ?> Thanks for this, I'm sure it will be very helpful mate. :) Quote
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.