Webmaster Forum
Go Back   Webmaster Forums UK SEO SEM Webmaster Community Forum - UKWW > General > General Webmaster Talk
Register FAQ Members List Downloads Calendar Today's Posts Webmaster Resources Webmaster Blogs

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-16-2007, 08:11 PM
midlandi
Guest
 
Posts: n/a
iTrader: / %
Default Making Search Engine Friendly URL

Making Search Engine Friendly URL


An htaccess file is a simple ASCII file. .htaccess is the file extension. It is not filename.htaccess or anyfile.htaccess. It is simply named .htaccess. This file has many usage including password protection, enabling SSI, deny users by IP, changing your default directory page, making search engine friendly URLs, redirects, adding MIME types and many more.

Search Engine Friendly URL
Search engines like Google are much better at indexing static pages rather than hyperlinks that contain query strings. The robots used by search engines have problems with dynamic pages. However, that dynamic hyperlinks can be changed to static one allowing them to crawl all the pages. This approach is good especially for search engine promotion and site ranking. For example:

http://www.mysite.com/view_computer.php?key=1

can be easily rewritten as

http://www.mysite.com/computer_1.html

thus eliminating the "?" sign in the URL.

The example shown above referred to a module called mod_rewrite. This is a module compiled into Apache web server. This will be the usage of .htaccess file we talked earlier. mod_rewrite makes use of the .htaccess to perform rewrites which in turn tells the server how to convert between static and dynamic URLs.

Check your server
Before we can create .htaccess file, we'll make sure that the server where our script running support the mod_rewrite module. If you have a web host, consult the technical support. If the support is not good (probably not coz most host offer 24/7), you can check it by viewing the phpinfo(). To do this, create a php file:

phpinfo();
?>

save it as info.php, upload it to your server, then on your browser type http://www.mysite.com/info.php. It will display lots of information, just look for the heading "apache" and then "Loaded Modules" and you must see mod_rewrite there and proceed to creating the file. If you're just running th scripts in your local machine, open the Apache configuration file - httpd.conf file and find the following line:

LoadModule rewrite_module

Make sure that it has no comment sign (#) before it.

Creating .htaccess
Now we're ready to create .htaccess. I recommend using text editor like Notepad to do this one. I'm assuming that the URL we are going to change is

http://www.mysite.com/view_computer.php?key=1

to

http://www.mysite.com/computer_1.html

Here's the code for .htaccess:

RewriteEngine On
RewriteRule ^computer_([a-zA-Z0-9]+)\.html$ view_computer.php?key=$1

Ok let's break it down. The first and second line is just a comment so no need to go through with it. Next I am forcing Apache to turn on the rewrite engine for the URL's using the RewriteEngine On.

* The caret (^) stands for "anything before" in the URL.
* The (computer_) will be the part of the new URL where the users redirected to.
* ([a-zA-Z0-9]+) is a variable as defined by the brakets. The conditions inside the brakets say that the variable can have small or uppercase letters and can have numbers only. The plus simply means it has no set limit to the number of characters or numbers. This allows for maximum compatability and expandability.
* The slash before the full stop, \, is used to make sure Apache understands that the full stop is a normal character and isn't being used as or with another function.
* .html will be the extension of the new URL.
* view_snippet.php is the real php page that we target and be replaced with the new one.
* key=$1 means that the first variable, the key defining one, is echoed in place of $1.
* Upload it to your server and job done!

Put in Action
You may be asking, where I'm going to put this or that. Let's say you have a database of computers and you have a page, say computerlist.php, that list all of it by name and each name has a link to view the detailed part of the computers listed. It may have the following code:

// Some stuff of queries here..
while($rows = mysql_fetch_array($query))
{
$key = $rows['ComputerId'];
$name = $rows['ComputerName'];

echo "" . $name . "";
}
?>

Change "" . $name . ""; to "" . $name . ""; making your final code look like this:

// Some stuff of queries here..
while($rows = mysql_fetch_array($query))
{
$key = $rows['ComputerId'];
$name = $rows['ComputerName'];

echo "" . $name . "";
}
?>

Don't stop right here, play with the .htaccess and you can have more complex dynamic URLs to change into a simple search engine friendly.

Source URL: http://www.triphp.com

About The Author
Ramil Alcibar is a contributor to TriPHP Webmaster Resources.
Digg this Post!Add Post to del.icio.usStumble this Post!Wong this Post!
Reply With Quote
Reply

Bookmarks

Webmaster Resources
UK WW SEO Tools
Find UK Hosts
 
The Forum Rules
Forum Rules - MUST READ
 
Site Of the Month
BizzFace
Nominate site of the month
 
Tag Cloud
.biz .us 100 pound 15000+ mobile wallpapers 19000+ mobile logos article database article site bagalibaba@hotmail.com bidding bidding directory bid directory bid for position buy a website cheap domains cmodz dabangla directory estdomains free space glype glype theme google http://www.bagalibaba.com international seo java games links marketing phones electronics promo promotion proxy script proxy theme purchase a website ranking 3 seo seo expert seo services site dump social web space theme three year old web vebtools.com for sale videos web directory web hosting website development wordpress work at home

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search engine friendly? temi General Webmaster Talk 14 09-14-2007 12:11 PM
Difference between search engine & meta search engine rakib General Search Engine Discussions 5 03-24-2007 02:08 PM
How far will you go in search engine search results? temi General Webmaster Talk 3 04-20-2006 08:14 AM
How to set up search engine friendly 301 page redirect temi General Search Engine Discussions 12 07-13-2005 08:55 AM
Make PHPbb more search engine friendly temi Marketplace (all other buy/sell/wanted) 6 08-31-2004 07:11 PM


All times are GMT. The time now is 01:20 AM.

UK Webmaster World Forums - Internet marketing, web development, domain names, SEO contest and discussuons.
Subscribe to our feeds   Subscribe to our feeds

Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151