velocite Posted March 22, 2008 Share Posted March 22, 2008 Hey everyone, I have been look this website, on how to clean urls, for example, instead of: "http://www.something.com/index.php?newsid=2" its, "http://www.something.com/news/2/" You guys can find the article here: http://www.alistapart.com/articles/succeed/ However my main problem is the code provided, I have no idea what to put in lines 21 and 29 the code is here: <?php //1. check to see if a "real" file exists.. if(file_exists($DOCUMENT_ROOT.$REQUEST_URI) and ($SCRIPT_FILENAME!=$DOCUMENT_ROOT.$REQUEST_URI) and ($REQUEST_URI!="/")){ $url=$REQUEST_URI; include($DOCUMENT_ROOT.$url); exit(); } //2. if not, go ahead and check for dynamic content. $url=strip_tags($REQUEST_URI); $url_array=explode("/",$url); array_shift($url_array); //the first one is empty anyway if(empty($url_array)){ //we got a request for the index include("includes/inc_index.php"); exit(); } //Look if anything in the Database matches the request //This is an empty prototype. Insert your solution here. if(check_db($url_array)==true()){ do_some_stuff(); output_some_content(); exit(); } //3. nothing in DB either Error 404! }else{ header("HTTP/1.1 404 Not Found"); exit(); } Quote Link to comment https://forums.phpfreaks.com/topic/97332-making-clean-urls/ Share on other sites More sharing options...
Lamez Posted March 22, 2008 Share Posted March 22, 2008 I have been wondering on how to do that. like myspace has it (myspace.com/username), but how do they do that? Quote Link to comment https://forums.phpfreaks.com/topic/97332-making-clean-urls/#findComment-498060 Share on other sites More sharing options...
velocite Posted March 22, 2008 Author Share Posted March 22, 2008 Please help Quote Link to comment https://forums.phpfreaks.com/topic/97332-making-clean-urls/#findComment-498077 Share on other sites More sharing options...
ryeman98 Posted March 22, 2008 Share Posted March 22, 2008 The correct term is Pretty URLs. http://www.somecoders.com/2006/07/pretty-urls-using-htaccess/ Quote Link to comment https://forums.phpfreaks.com/topic/97332-making-clean-urls/#findComment-498084 Share on other sites More sharing options...
velocite Posted March 22, 2008 Author Share Posted March 22, 2008 The correct term is Pretty URLs. http://www.somecoders.com/2006/07/pretty-urls-using-htaccess/ Ohh , thanks for the link So are you saying that I dont need all that php code? Quote Link to comment https://forums.phpfreaks.com/topic/97332-making-clean-urls/#findComment-498085 Share on other sites More sharing options...
lordfrikk Posted March 22, 2008 Share Posted March 22, 2008 The correct term is Pretty URLs. http://www.somecoders.com/2006/07/pretty-urls-using-htaccess/ Ohh , thanks for the link So are you saying that I dont need all that php code? If your hosting has mod_rewrite or similar solutions enabled, then you don't need any this php code. Quote Link to comment https://forums.phpfreaks.com/topic/97332-making-clean-urls/#findComment-498088 Share on other sites More sharing options...
ryeman98 Posted March 22, 2008 Share Posted March 22, 2008 The correct term is Pretty URLs. http://www.somecoders.com/2006/07/pretty-urls-using-htaccess/ Ohh , thanks for the link So are you saying that I dont need all that php code? If the mod_rewrite is enabled on your site then yeah, you don't need it. .htaccess will do you lots of good. Quote Link to comment https://forums.phpfreaks.com/topic/97332-making-clean-urls/#findComment-498089 Share on other sites More sharing options...
velocite Posted March 22, 2008 Author Share Posted March 22, 2008 so even if it doesn't, i can write it in yea? Quote Link to comment https://forums.phpfreaks.com/topic/97332-making-clean-urls/#findComment-498090 Share on other sites More sharing options...
mVeliki Posted March 22, 2008 Share Posted March 22, 2008 Without mod_rewirite support, you can try to read PHP_SELF constant, in some systems it contain whole path so you can analyse it. Quote Link to comment https://forums.phpfreaks.com/topic/97332-making-clean-urls/#findComment-498230 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.