I'm in the middle of making some stuff for LinksJuice.com including a search function But i wanted to make the detail pages have the website title in the URL like you have probably seen alot of PHPLD directories doing. I personally like backlinks from these types of detail pages, so I decided to take a look at what I needed to do.. I noticed site-sift had originally attempted on doing this but made an error in a piece of code so it didn't work! The new linksjuice detail pages are looking like this instead of that (now gets redirected to homepage). If your a site-sift user, theres a really simple way of doing this which is shown below; Open up pages.php and find <? echo gLink($spages['title'],'detail',$page['id'],$myconn); ?> Code (markup): Change that to; <? echo gLink($page['title'],'detail',$page['id'],$myconn); ?> Code (markup): Now do the same on spages.php!! There is only one problem now, both the new and old detail page URLs work due to dodge coding. So the only way I could stop the old one from working was to redirect the old ones to the homepage with a 301 header; Open your htaccess file, you should have something like; RewriteRule ^(.*)-(.*)-(.*).html$ index.php?go=$2&id=$3 [L,NC] Code (markup): Now change that to RewriteRule ^(.*)-(.*)-(.*).html$ index.php?go=$2&id=$3&resource=$1 [L,NC] Code (markup): Now open your index.php and add this to the top; <?php require_once('Connections/myconn.php'); require_once('include/myfunctions.ini.php'); if($_GET["go"] == "detail"){ $id = $_GET["id"]; $resource = $_GET["resource"]; $query_page = "SELECT * FROM pages WHERE id = \"$id\""; $page = mysql_query($query_page, $myconn) or die(mysql_error()); $row_page = mysql_fetch_assoc($page); $keywords = $row_page['title']; $keywords = eregi_replace("[^a-zA-Z0-9_ ]",'',$keywords); $keywords = str_replace(' ','_',$keywords); $keywords = eregi_replace("[_]+",'_',$keywords); if(!preg_match("/$keywords/", "$resource")){ Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: http://www.YOURDOMAIN.com"); } } ?> Code (markup): I think thats everything!! I'm just trying to help the good ol' site-sift users out heh, so I will not be hold responsible for any damage caused, and sorry if my codes messy or just plain stupid
Thanks Amit! Oops, I knew I had forgotten something Open includes/myfunctions.ini.php Find #gLink Function -- return a href for a <a> tag pending mod rewrite setting Then replace the whole gLink function with; #gLink Function -- return a href for a <a> tag pending mod rewrite setting /*string go, string id, mysql connection $mycon*/ function gLink($keywords,$go,$id,$myconn,$page=false){ global $LINK_BASE; if($go == 'detail'){ $sql = "select * from settings where id = '1'"; $r = mysql_query($sql,$myconn); $settings = mysql_fetch_assoc($r); if($settings['directLink'] == 'No'){ $sql = "select url from pages where id = '" . $id . "'"; $r = mysql_query($sql,$myconn); $page = mysql_fetch_assoc($r); return $page['url']; } } $keywords = eregi_replace("[^a-zA-Z0-9_ ]",'',$keywords); $keywords = str_replace(' ','_',$keywords); $keywords = eregi_replace("[_]+",'_',$keywords); if($_SESSION['MM_UserGroup'] == 'Admin') {//disable seo urls if loged in as admin $return = 'index.php?go=' . $go . '&id=' . $id; if ($page > '0') { $return .= '&pageNum_pages=' . $page; } return $return; } $sql = "select seoUrl from settings where id = '1'"; $results = mysql_query($sql,$myconn) or die(mysql_error()); $settings = mysql_fetch_assoc($results); if($settings['seoUrl'] == 'Yes'){ if($go == 'detail') { return $keywords . '-' . $go . '-' . $id . '.html'; } else { $return = $LINK_BASE . $id . '/' . $keywords . '/'; if ($page > '0') { $return .= $page . '/'; } return $return; } // return $keywords.'-'.$go.'-'.$id.'.html'; } else { $return = $LINK_BASE . 'index.php?go='.$go.'&id='.$id; if ($page > '0') { $return .= '&pageNum_pages=' . $page; } return $return; } }//end gLink function Code (markup):
Great contribution, it's what i was looking for Thanks for the detailed tutorial will try on ElegantDirectory soon.