Page 1 of 1

Search Engines Friendly links...

Posted: Fri May 25, 2007 12:53 pm
by NTGr
Hello.
I m trying to understand what is the best way to build my links..
Any Help ???

So far i m building my links this way...
For my HomePage... http://localhost/index.php?p=homebody
For the categories...http://localhost/index.php?p=display&cid=1
and for the items....
http://localhost/index.php?p=display&ci ... =EuroDance VINYL AristName ArtistSong

What you think???

Posted: Fri May 25, 2007 1:36 pm
by alex.barylski
Those would be consider non-search engine friendly links is what I think :)

However, most search engines now do spider those links, I am still in the boat that believes dynamic-looking links still rank lower than static-looking links.

http://www.domain.com/articleid/10

http://www.domainc.com/index.php?articleid=10

The first is what would be considered a "clean" url the latter is what is considered a non search friendly URL

Posted: Fri May 25, 2007 1:41 pm
by Chris Corbyn
Remember that the only interface is not just the GUI (the page). The URL is actually part of the interface too and making it friendlier for end users makes your overall apllication easier to use. Users can make educated guesses on how to modify the variables in the URL. Users will feel more comfortable changing what looks like a path, compared with changing something with a load of ? & = in it.

EDIT | For some research points look at mod_rewrite and the Front Controller design pattern with a request router.

Thnx....

Posted: Sat May 26, 2007 3:41 am
by NTGr
Thnx..
IF i uderstand correctly i sould use mode_rewrite to RECREATE the LINKS ....RIGHT???

This will effect the way my pages work?? since cid & pid are values used by several functions

Thnx again....

Re: Thnx....

Posted: Sat May 26, 2007 4:07 am
by Chris Corbyn
NTGr wrote:Thnx..
IF i uderstand correctly i sould use mode_rewrite to RECREATE the LINKS ....RIGHT???

This will effect the way my pages work?? since cid & pid are values used by several functions

Thnx again....
mod_rewrite takes a URL like http://localhost/foo/bar/x/y and transparently turns it into the correct form http://localhost?foo=bar&x=y for example. You define those rules. If you have hard-coded links into your application which point to the & ? = form of the URL then you'll have to recode all those to be friendly links. It's good practise to "build" all URLs in your application with a function you create, such as create_url($path). For example rather than hard-coding:

Code: Select all

<a href="?module=checkout&action=confirm&order=1234">Confirm your order</a>
Do this:

Code: Select all

<a href="<?php echo create_url("/checkout/confirm?order=1234") ?>">Confirm your order</a>
That function then needs to understand the string you're passing it in order to make the friendly URL. Here I assume that there will always be a /module/action part in the URL. You could make the function easier to write by passing 3 arguments $module, $action, $args. You can slo have the function lookup rules defined in your routing configuration. See below.

mod_rewrite can be used to play a fairly minor part in friendly URLs. If you can set up mod_rewrite to simply prepend index.php/ then you get URIs like /some/friendly/url mapped to something like:

/index.php/some/friendly/url

You can then break that down in your own code and work out where to direct the request. Using the approach allows you to change your routing rules without changing your web server configuration. Any helper functions for building friendly URLs in your application can now be a bit more flexible/dynamic too.

Posted: Sat May 26, 2007 4:25 am
by NTGr
It's good practise to "build" all URLs in your application with a function you create, such as create_url($path). For example rather than hard-coding:
Can you pls give me a HINT how this function must be ???
OR
some links(tutorials) to read more about ??

Thnx Once again.....

Posted: Sat May 26, 2007 5:09 am
by s.dot
There's a class I built for making clean URLs in the "code snippets" forum.

Thnx..scottayy

Posted: Sat May 26, 2007 6:45 am
by NTGr
Thnx scottayy.....
:D 8)