php - URL rewrite and robots.txt -


i have made urls seo friendly i.e.

http://mydomain.com/topic/title-of-page 

previously, url of above page was

http://mydomain.com/search?id=6567889 

now google still showing second url in search results. question if disallow /search in robots.txt, google stop crawling page altogether or still crawl mydomain.com/topic/title-of-page i.e. new url?

thanks lot help. sorry spaces in url wouldn't let me post them

seb

you'll want fix right away. there going issues duplicated content on site in regard seo.

to cut half of search engine traffic site, add robots.txt file:

user-agent: * disallow: /search.php 

that way none of search engines mine old link. may still have cached search results. being said you'll need handle each of pages serve 301 redirect you're not penalized. tell them update cache.

additionally you'll want add sitemap.xml file contains proper urls on server in order of priority.

assuming have new path stored in db, you'll need search.php. way can keep urls seo. 301 permanent redirect.

if(preg_match('!^/search!',$_server['request_uri'])){   $tempid = $_get['id'];   $tempid = mysqli_real_escape_string($tempid);    $query = "select count(*) table id=$tempid";    $count = mysqli_result(mysqli_query($db_link,$query),0);  if($count==1){   $query2 = "select correctpath  table id=$tempid";   $correctpath = mysqli_result(mysqli_query($db_link,$query2),0);    header( "http/1.1 301 moved permanently" );    header( "location: $correctpath" );    exit();   } else {   //non-existent id    header( "http/1.1 301 moved permanently" );    header( "location: /" );    exit();   }  } 

otherwise replace second query function you're using build paths.

you add .htaccess file every entry, it's not future proof , larger list, longer process (more server overhead).

rewriteengine on rewriterule ^search\.php\?id=1  /page1_new_path/ [l,r=301] rewriterule ^search\.php\?id=2  /page2_new_path/ [l,r=301] 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -