Welcome Guest, Not a member yet? Register   Sign In
SEO Friendly url (still get id from address bar, but display data name)
#1

[eluser]artlover[/eluser]
Hi friends,

I'm building my first project with Codeigniter. I love it, I enjoy so much Smile
I have an issue about SEO friendly url.

my current url:
domain.com/client/43

I get id from address bar to get client details from db. any chance to change url like;
domain.com/client/blabla-company-bla

and still get my data from db somehow?

thanks a lot!!
#2

[eluser]Dam1an[/eluser]
Assuming you can gaurantee each client name will be unique, yes
If not, you could always do
domain.com/client/client-name-goes-here/123
#3

[eluser]artlover[/eluser]
[quote author="Dam1an" date="1248981219"]Assuming you can gaurantee each client name will be unique, yes
If not, you could always do
domain.com/client/client-name-goes-here/123[/quote]

thanks for answer : )

client names are unique. but at your example, i still depend on id (/123). i need to reach the page with type of url domain.com/client/client-name
#4

[eluser]artlover[/eluser]
if I use like
domain.com/client/client-name

does it mean, I will have to get data from db with client name, not with id?
#5

[eluser]Dam1an[/eluser]
yeah, you should just need to change the query in your model to use client name instead of id in the where clause Smile
#6

[eluser]artlover[/eluser]
[quote author="Dam1an" date="1248981706"]yeah, you should just need to change the query in your model to use client name instead of id in the where clause Smile[/quote]

so I will have to replace the - at adressbar url with space for matching with the db client name. or is there any cool trick at CI for that? : )
#7

[eluser]Phil Sturgeon[/eluser]
Add an extra 'slug' field which should be a UNIQUE key in the SQL. When you create the item store a version of the title using url_title() then match the slug in the URL against the one in the DB.
#8

[eluser]artlover[/eluser]
[quote author="Phil Sturgeon" date="1248982405"]Add an extra 'slug' field which should be a UNIQUE key in the SQL. When you create the item store a version of the title using url_title() then match the slug in the URL against the one in the DB.[/quote]

Thanks Phil,
do you mean generating a unique key from record title? sorry I'm a bit confused of your way. : /




Theme © iAndrew 2016 - Forum software by © MyBB