Jump to content

Making clean URLs


velocite

Recommended Posts

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();
}

Link to comment
https://forums.phpfreaks.com/topic/97332-making-clean-urls/
Share on other sites

 

Ohh  :o, 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.

Link to comment
https://forums.phpfreaks.com/topic/97332-making-clean-urls/#findComment-498088
Share on other sites

 

Ohh  :o, 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. ;)

Link to comment
https://forums.phpfreaks.com/topic/97332-making-clean-urls/#findComment-498089
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.