Hello and welcome to the Webmasters Forums!. This is the best place to get webmasters resources for free. Get $2 for free today, read more - Make your payment today. Download premium and professional templates for free. Get free web hosting without ads, read more. You can get lot more by simply join with this forum. To gain full access to the forums you must sign up for a free account.


Post Reply  Post Thread 

Tutorial-how to make search engine frendly url with .htaccess

Post Bank
Posting Manager
******

Posts: 995
Group: Forum Team
Joined: Sep 2006
Status: Online
Make money from now. You can make money just for posting on this forum. Every discussions on this community gives you more money. $2 minimum payout. So get your payment today, SignIn with this forum.

Signin to Remove this Post

Dhanraj
Senior Member
****


Posts: 272
Group: Registered
Joined: Aug 2007
Status: Offline
Reputation: 1
Points: 99 (Donate)
Post: #1

Tutorial-how to make search engine frendly url with .htaccess


Here i will post a way to declare our url friendly for search engines:

Quote:
Mod_Rewrite Using HTACCESS

Having search engine friendly urls can help out a lot with your rankings as everyone by now knows the ? mark in a dynamic page's url can sometimes throw a search engine off. A .htaccess file can really be a great help. .htaccess is a file extension. It is not file.htaccess or any other similar combination. So when you save your .htaccess that's what you call it simply .htaccess. I recommend using HTML Kit to save your file with as well. You can download it here.

Here's a simple code for a .htaccess I use for one of my .php driven sites. RewriteEngine on
RewriteRule ^srch/([^/\.]+)/?$ index.php?srch=$1 [L]


Using this code saved as a htaccess file can turn this search/music/index.php?srch=-Bing%20Crosby into this search/music/srch/Bing+Crosby. The page in question is a php page that is coded to do a simple search of a database and pull in posters from whatever term is used to search for.

So this search/music/index.php?srch=dogs pulls in pictures of dogs, this one cats - search/music/index.php?srch=cats etc etc.. All the htaccess does is allow you to pull up results without using the question mark. Basically this line "RewriteRule ^srch/([^/\.]+)/?$ index.php?srch=$1 [L]" says replace " index.php?srch=" with this "srch". Thus srch with a / and the search term equals the dynamic web page your trying to pull up.

Try it this php page http://fine-art-prints.ws/srch/john+wayne . Just change the word john wayne to whatever you want like dogs, cats, birds, whatever pictures you would like to see. If it weren't for the htaccess file all you would get is page not found unless you used index.php?srch= at the end of the url of course.

Here's a more detailed article I found from Bobby Handzhievz that may help you with htaccess as well.

MOD_REWRITE for Dummies
by Bobby Handzhiev

A short article in human language

This article is not a complete guide to Apache's mod_rewrite neither to .htaccess.
Its purpose is to help you - the webmaster - to create "mod_rewritten" versions of your dynamic webpages even if you have limited technical knowledge.
I won't show you all the tips-and-tricks - my aim is to bring all the complexity of the Apache's documentation to 1-2 pages of human language - easy and fast.

What is mod_rewrite?

Mod_rewrite is Apache extension which allows you to "rewrite" the URLs of your web pages.
If your server supports this technology (most linux webhosts do nowadays) you are able to rewrite virtually any URL into anything you like. Most often it is used to rewrite the URLs of dynamically generated webpages such as http://www.mywebsite.com/index.php?par1=...&par3=2...
This can easy be 'translated' into http://www.mywebsite.com/par1/par2/par3

Why mod_rewrite?

- Search engine optimization - there are a lot of debates on this topic, but it is still
true that the static-looking links rank better than the dynamic ones.
Here is a confirmation from Google on that topic:

"Your pages are dynamically generated. We're able to index dynamically generated pages. However, because our web crawler could overwhelm and crash sites that serve dynamic content, we limit the number of dynamic pages we index. In addition, our crawlers may suspect that a URL with many dynamic parameters might be the same page as another URL with different parameters. For that reason, we recommend using fewer parameters if possible. Typically, URLs with 1-2 parameters are more easily crawlable than those with many parameters."

- User-friendliness - Some users remember the URLs visally. Even if they bookmark, they can easier recognize a link like http://www.mywebsite.com/services.html than http://www.mywebsite.com/index.php?task=12 for example.

- Security - mod_rewrite helps you hide the parameters passed in the application. Basically your dynamic pages should be secure enough even without mod_rewrite. But hiding the parametters will decrease the danger of attack

How to use it?
Mod_rewrite is really powerful if you are familiar with the regular expressions which it uses.
But learning the whole pattern syntax can be quite complicated, especially for the non-technical user. That's why I'll teach you at several simple patterns which are pretty enough to get your website URLs rewritten.

Lets start:
First you need to create a file called .htaccess and place it exactly in the folder where you want the rewriting to take effect (it will also take effect over all subfolders). In case you already have a .htaccess file you can simply add the lines to it (if it already has mode_rewrite directives you can mess them however).
Open it in a simple text editor an start with:

Options +FollowSymLinks
RewriteEngine on

Now the rewrite engine is switched on. You can now start adding as many rewrite rules as you want. The format is simple:

RewriteRule rewrite_from rewrite_to

Here "RewriteRule" is static text, i.e. you should not change. "rewrite_from" is the address which will be typed in the browser and "rewrite_to" - which page the server will actually activate. Both of these can contain "masks", but in "rewrite_to" we will only use $ and will discuss more or "rewrite_from" part. Let me "meet you" with the very few masks you'll need and bring you some samples. You'll see how easy is it.

Let's stop talking theory and see an example. Let's imagine your server runs an e-shop, which
uses URLs like index.php?task=categories to list the categories, index.php?task=category&id=5 to show a category contents and other parametters in 'task' to do other things.

RewriteRule ^(.*).html index.php?task=$1

What does all that mean? This is a rewrite rule which allows you to make your URLs looking as "static". In this example categories.html will be "translated" to index.php?task=categories.
So you no longer need dynamic URL to list ther categories, but can write categories.html

But what do all these strange characters mean?
- ^ character marks the beginning. I.e. you tell the server that it should not expect anything before it.
- (.*) - This combination is the most often used and it means literally "everything". So everything you type before ".html" (i.e. your fake file name) will be passed as:
- $1 - This is a parametter, saying where the first mask should be put. If you have more than one masks (masks are everything which you use to represent dynamich text or file names) you can use $2, $3 etc. You'll seemor ein the following examples.

So, if you have categories.html it will be translated info index.php?task=categories, services.html into index.php?task=services etc...

What if you have more than one parametter? First, you should use some characters as delimiter:

RewriteRule ^(.*)-(.*).html index.php?task=$1&language=$2

Here how you can also pass task and language. For example:
categories-englist.html will be translated into index.php?task=categories&language=english.

IMPORTANT: If you first write
RewriteRule ^(.*).html index.php?task=$1
The second one may not work. You need to always start from the most complicated rule to the simplest one.

Make it Better:
The rule (.*) is too general and often may prevent you of making more complicated rewriting rules. So it is recommended that you "limit" the rules into something more concrete. Here are a couple of advices:

- Use the "OR" operator. In our e-shop example we have only few possible "tasks" passed to index.php. Lets say:
index.php?task=categories
index.php?task=category
index.php?task=product
index.php?task=services

What will happen if you want to use your static file about.html? It will be rewritten into index.php?task=about and won't work. So you can use the OR operator and limit the rewriting only to the cases you need:

RewriteRule ^(categories|category|product|services).html index.php?task=$1

This tells the server to rewrite only if the file name is categories.html OR category.html OR product.html OR services.html

- Using "numbers". You can easy limit the rewriter to rewrite if it meets only numbers at a certain place:

RewriteRule ^category-([0-9]*).html index.php?task=category&id=$1

With ([0-9]*) mask you tell the rewrite engine that on the mask place it should expect onlly numbers. So if it see category-english.html it won't rewrite to index.php?task=category&id=english, but to index.php?task=category&language=english (because of the rule we have shown above - RewriteRule ^(.*)-(.*).html index.php?task=$1&language=$2.).

Complete example: Here is how will look the final .htaccess file for our imaginary e-shop:

--------
Options +FollowSymLinks
RewriteEngine on

RewriteRule ^(.*)-(.*).html index.php?task=$1&language=$2.
RewriteRule ^(categories|category|product|services).html index.php?task=$1
RewriteRule ^category-([0-9]*).html index.php?task=category&id=$1
About the Author
The author is Senior Deveoper in PIM Team Bulgaria and Consultant in SEO PIM Team


got from a e-book


Free cash for surveys

Our Great indian forum

Pretty good PTC-Real

Anonymize your links

This post was last modified: 13-09-2007 09:00 PM by Dhanraj.

13-09-2007 08:56 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ivenms
Administrator
*******


Posts: 2,179
Group: Administrators
Joined: Sep 2006
Status: Offline
Reputation: 14
Points: 4389 (Donate)
Post: #2

RE: Tutorial-how to make search engine frendly url with .htaccess


Very good information.

This site also using the same feature to make our URLs user friendly.

But now, I don't think that you can benefit from this activity. Search engine developers are not fools. They already developed many other ways to find if the files are static or not.

I also don't think that now search engines give more preferences to static pages. Google and other search engines treat dynamic pages same as static pages.


Read: General Rules & Policies before posting.
Make Money By Posting | Earning and Exchanging Points | Add Your Links
14-09-2007 03:08 AM
Find all posts by this user Quote this message in a reply
Dhanraj
Senior Member
****


Posts: 272
Group: Registered
Joined: Aug 2007
Status: Offline
Reputation: 1
Points: 99 (Donate)
Post: #3

RE: Tutorial-how to make search engine frendly url with .htaccess


may be something as you posted ivenms,but i think it is a new information.Also Google and altavista have some deffects too.They are unable to block phishing sites,stealers and cant block private info like passwords,credit card numbers,also one can search google to find a way to h@ck google


Free cash for surveys

Our Great indian forum

Pretty good PTC-Real

Anonymize your links
14-09-2007 10:53 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ivenms
Administrator
*******


Posts: 2,179
Group: Administrators
Joined: Sep 2006
Status: Offline
Reputation: 14
Points: 4389 (Donate)
Post: #4

Is search engine capable of Maintaining Security? Defects of Google


Dhanraj Wrote:
may be something as you posted ivenms,but i think it is a new information. Also Google and altavista have some deffects too.They are unable to block phishing sites, stealers and cant block private info like passwords, credit card numbers, also one can search google to find a way to h@ck google


Google can ban your site from their search entries if they find your site violating their terms of service. They some times even gives warning to the visitors if they found some bad reports with the entry.

The work of blocking private informations not depends on the search engines. That job is completely depends on the web sites which deals with secured informations and pages. You can block a page from indexing with the help of robot.txt file.


Read: General Rules & Policies before posting.
Make Money By Posting | Earning and Exchanging Points | Add Your Links
14-09-2007 11:16 PM
Find all posts by this user Quote this message in a reply
walsh
Senior Member
****


Posts: 401
Group: Registered
Joined: Oct 2006
Status: Offline
Reputation: 0
Points: 680 (Donate)
Post: #5

RE: Tutorial-how to make search engine frendly url with .htaccess


ivenms Wrote:
Google can ban your site from their search entries if they find your site violating their terms of service. They some times even gives warning to the visitors if they found some bad reports with the entry.


That is new information for me. I saw many sites that warn by google when we try to enter into those pages. Then why they allowed those pages on google without banning those sites?


05-10-2007 04:08 AM
Find all posts by this user Quote this message in a reply
Lord_Daksh
Posting Freak
*****


Posts: 643
Group: Registered
Joined: Sep 2007
Status: Offline
Reputation: 0
Points: 16 (Donate)
Post: #6

RE: Tutorial-how to make search engine frendly url with .htaccess


Hi friends,please help me now. My forum is now located at http://www.potuj.org and all forum pages and sub pages are showing like this, http://potuj.org/viewforum.php?f=3

But i want to show it like this, http://potuj.org/........xyz.html



Please say me what to do..


Plz help and say me how to install this mod and get my links well...


EARN EASY 50$ IN 10 DAYS!
FREE CALLS,GPRS,SMS,MMS TRICKS,FULL MOVIES,FREE RAPIDSHARE
80$ IN 1 DAY! 20$/REFERRAL!!
26-02-2008 12:21 AM
Visit this user's website Find all posts by this user Quote this message in a reply
shadav
The Forgotten One
******


Posts: 394
Group: Super Moderators
Joined: Oct 2006
Status: Offline
Reputation: 2
Points: 1058 (Donate)
Post: #7

RE: Tutorial-how to make search engine frendly url with .htaccess


what version of phpbb are you running? if v3.x there's a SEO mod
http://www.phpbb.com/community/viewtopic...9&t=691165
will rewrite the urls to the way that they are here

not sure if there's one for v2.x I'd assume there was one but i'm not finding one...


Foamy Fanatics Fan Site
Webmasters Resource Forum Photos For Sale
26-02-2008 07:45 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites
Rate This Thread:

Forum Jump:

Sign In to Remove Ads

Download 1000's of web templates. Unlimited access!
World's Best Web Hosting
Website of the Month

Create-a-Page for Free
SOTM June 2008


Accepting Submissions
for July 2008
Resources

Recommended Sites:



Visit our Sponsors!

Current time: 07-09-2008, 06:49 AM


Copyright © 2002-2008 MyBB Group
Powered By MyBB