Building a sufficient php site

To get more popular search engine rank, a new webmaster must make sure that they do their keywords homework. There are several ways to do this, with Wordtracker being the most popular. Once you have done your homework and have great keyword phrases, then register your domain and start building your site.

If you are running a php/mysql website, then you will have urls that look like this: http://yoursite.com/index.php?task=view&id=1 or something of that nature. You can change the urls, if your server allows for ModRewrite by utilizing a small file that is planted on the server. The file name is .htaccess. Now, to rewrite the files, you will need to write the file in a text editor and simply save as .htaccess or .htaccess.txt and rename on server by removing the .txt extension. In this file, using a url like the one listed above, you will want to write the .htaccess like this:


Options -Indexes
RewriteEngine on
RewriteRule ^([0-9]+)-([a-zA-Z0-9?-]+) index.php?task=view&id=$1&name=$2 [L]
RewriteBase /

Now is time for the php code to rename the urls. This can be done in a separate php file if so desired or on the pages that query for the urls on the site. If you use the latter, your code can look something like this.

<?php
$sql = mysql_query("SELECT * FROM table_in_datbase_where_info_is");
$row = mysql_fetch_assoc($sql);
$url_1 = $row['id'].'-'.$row['name'];

That will query the database and get you a link that would look like this:
1-Your url name
Now that we have done this, we will use php str_replace to make the link look friendlier.

$url_1 = str_replace(" ","_",$url_1);

That will remove the spaces and replace them with an underscore. Now to tie it all in together:

$url = "http://yoursite.com/".$url_1.".html";
echo "<a href='".$url."'>$row['name']</a>";
?>

This will now make your urls look like this: http://yoursite.com/1-Your_page_or_post_name.html. With the .htaccess file that we placed earlier, it will look for that url and place it with the same url as before based on the id of your page being 1 or the first entry found in your database. It will automatically rename every entry in the database in that table and will increase your sites search engine popularity.

When your url matches the keywords of the popular searched phrase with little competition, you will soon start to see a steady flow of traffic from the search engines.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>