0

In My Application
We can access user profile screen by any of next URLs format

http://example.com/users/123/
http://example.com/users/123/mike
http://example.com/users/123/mike-pedro

But the problem is that
Now many URLs will show the same content
Because i dont care about last {slug}, i only use {id} to show the content
And according to http://blog.codinghorror.com/url-rewriting-to-prevent-duplicate-urls/

That will lowers my PageRank
And divvied up between the 3 different URLs instead of being concentrated into one of them.

When i checked stackoverflow implementation
I found
The 3 different URLs will directed to the same content and the same URL
for example
All next 3 links
https://stackoverflow.com/users/1824361/
https://stackoverflow.com/users/1824361/yajli
https://stackoverflow.com/users/1824361/yajli-maclo

ALL Will directed to one target URL and show its content
https://stackoverflow.com/users/1824361/yajli-maclo

The target link = {id} + {slug}

How to implement that using codeigniter

Community
  • 1
  • 1
Ahmed Nabil
  • 17,392
  • 11
  • 61
  • 88

1 Answers1

1

In your controller you can change the method where you'll be sending the ID to a model (with 1 argument - $id) that will return the "slug" (name) from the table for that specific ID.

With these you can then call another method in the controller that will take 2 arguments (Id and slug). This will make the link look like this: example.com/users/123ID/blaSlug

So if you access the first method, he will do the job and go to the second method.

Hope this helps

Cheers

John M.
  • 76
  • 1
  • 4
  • 11