CodeIgniter Forums
Friendly urls... What's your preference? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Friendly urls... What's your preference? (/showthread.php?tid=21131)

Pages: 1 2


Friendly urls... What's your preference? - El Forum - 07-31-2009

[eluser]tomdelonge[/eluser]
So, say for example you have a forum. And you want someone to be able to view a topic. What would you do?:

1) example.com/view/topic/243/

OR

2) example.com/view/topic/this-is-a-title/

OR

3) example.com/view/topic/243/this-is-a-title/

Here's the dilemma:
Case 1 is simplest to program. It isn't a very descriptive url however.
Case 2 is very descriptive, but does it always work? It seems like it would be harder to do (how do you guys do it).
Case 3 is descriptive, easy to program, but a little long.

Also, with case 3, this would work:

example.com/view/topic/243/this-is-not-the-correct-topic-title/

would work just as well (since i'd only look at the number segment)

Your thoughts? Suggestions? Thanks...


Friendly urls... What's your preference? - El Forum - 07-31-2009

[eluser]M Moeen uddin[/eluser]
right now i m folloing First case. and used one time case 2, but i m planning to adapt case three.

Case 3 is descriptive [good], i think long is also good [if you r thinking the request header will be heavy or something ], i think longness will help in seo all(?)
in program, i think the record will be taken by the id only, in case if the title changes/modifed by the user himself, then we should keep a separate option of permanent link (?)

I have also seen people enctrying ids with some key and giving urls like: example.com/view/topic/ASD34XZ

which later resolves into the id, [disable the evasdrapping]. I think this is safe.

So what about:
example.com/view/topic/ASD34XZ/with-the topic-title

-monee


Friendly urls... What's your preference? - El Forum - 07-31-2009

[eluser]tomdelonge[/eluser]
I like the idea of changing the id back and forth, it seems like the user will then know less about the database (like how many threads there are).


Friendly urls... What's your preference? - El Forum - 07-31-2009

[eluser]jedd[/eluser]
Approach #1.

Trying to obfuscate a Forum URL .. ? Why? And WHO do you think is trying to hack your forums?

Longevity of URL's is something that I think a lot of people underestimate the importance of. Changing the URL for a given page is not, generally speaking, A Good Thing. Consider what happens when, as a good CI forum citizen, you modify a forum thread that had a topic that succinctly describes a problem you were having, by inserting (SOLVED) into the subject field. If the subject field is the URL, every extant link to that thread will now fail. This, to spell it out, would be A Bad Thing.

Consider the URLs used on this forum as a good example. Unique, succinct, with sufficient meaning to be helpful, and a guaranteed longevity no matter if the thread moves forums or has a name change.


Friendly urls... What's your preference? - El Forum - 07-31-2009

[eluser]tomdelonge[/eluser]
except, if the word part of the url is meaningless... the method would only look at the id. you know?


Friendly urls... What's your preference? - El Forum - 07-31-2009

[eluser]jedd[/eluser]
[quote author="tomdelonge" date="1249103315"]except, if the word part of the url is meaningless... the method would only look at the id. you know?[/quote]

Explain in more detail how you envisage this working.

Under what circumstances, for example, would the word part be meaningless? What happens if the word part has meaning that conflicts? Would the word part ever out-rank the ID part? If not, then what point does the word part have? If you say it provides meaning to the person looking at the URL - how do they get that URL if not from a link (replete with plenty of meaning and context) elsewhere on your site? If they get it through a non-your-site source, say email, why is this preferable to someone emailing a URL and saying 'there's this thread about pointless URL components - it's not worth reading but here's the URL anyway'?


Having said that, I find mailing list archive URLs, usually in a format that includes yyyy/mm/dd, are very handy when browsing around the google results page - it lets me triage things very quickly based on vintage of the information, especially if I'm looking for a problem that I know cropped up around a certain date. I have pondered ways of doing this with a forum system, but nothing (that isn't grossly inelegant) sprung to mind.


Friendly urls... What's your preference? - El Forum - 07-31-2009

[eluser]M Moeen uddin[/eluser]
jedd,

if there is a case in which you want to secure your content against crawlers, all you can do make it a bit difficult .. or you said obfuscate it. a site which has no such information and does not feel to that the information avaialable in any sense become abuse to server or something... what you do then?

i think its about security. Before someone hacks, we can atleast read the precautionary measures. thats my choice.


Friendly urls... What's your preference? - El Forum - 07-31-2009

[eluser]John_Betong[/eluser]
[quote author="tomdelonge" date="1249100095"]So, say for example you have a forum. And you want someone to be able to view a topic. What would you do?:
...
...
...
Your thoughts? Suggestions? Thanks...[/quote]
 
 
I am in the process of trying to resolve this problem and to try and increase my SEO "brownie points".
1. I used to have "...com/joke/view/123/
2. changed to this "...com/joke/show/123/
3. then changed to "...com/joke/show/this_is_a_funny_joke/123
4. later changed to ...com/joke/_of_the_day/this_is_a_funny_joke/123

Items 1,2 and 3 are now redirected to '/joke/of_the_day/'

My controller code:
Code:
//=============================================
//
//  ensure parameters are in the correct order
//
//=============================================
function of_the_day($joke_title='Joke_of_the_day', $joke_idx = 123456)
{
  // ensure at least one parameter is numeric
  // make into the correct order
  if (is_numeric($joke_title))
  {
    $joke_idx = $joke_title;
    $data     = $this->m_lib->m_getjoke(NULL, $joke_idx);
        
    $joke_title    = url_title($data['joke_title'], '_');
        
    // now put in the correct order and permanently redirect
    redirect('/joke/of_the_day/' .$joke_title .'/' .$joke_idx, 'location', 301);
    exit;
  }else{
    $data = $this->m_lib->m_getjoke(NULL, $joke_idx);
    /* // results
      [joketitle]  => Joke of the day
      [joke_title] => Did you know
      [joke_id]    => 946        
      [joke_memo]  => Michael Jordan having "retired," with $40 million ...  
    */
  }    
  // remove trailing slash to make consistent with Googles "Duplicate meta descriptions"
  $data['joke_id']    = str_replace ('/', '', $data['joke_id']);
            
  $this->j_view($data);
}//endfunc
 
 
 
 


Friendly urls... What's your preference? - El Forum - 07-31-2009

[eluser]tomdelonge[/eluser]
[quote author="jedd" date="1249103677"]
Explain in more detail how you envisage this working.
[/quote]

Well, the only part of the url that would be looked at (by the method) would be the number part. So,

/123/this-is-real/

would be the same as:

/123/this-is-not-real/

It wouldn't make a difference to the application, but when your app creates links (and displays them on the page) the url would appear correctly. When I say meaningless, I mean the application isn't checking up on it at all. It just ignores that part of the url.


Friendly urls... What's your preference? - El Forum - 07-31-2009

[eluser]jedd[/eluser]
[quote author="tomdelonge" date="1249107644"]
/123/this-is-real/

would be the same as:

/123/this-is-not-real/
[/quote]

This might not worry you -- it definitely doesn't worry me -- but apparently this causes web crawlers to doubt the quality of your site.

In any case, I haven't heard the answer to my basic question (there were lots of question marks in my last two messages, I know) which could be distilled simply into 'why?'.

Or, if you prefer 'what problem are you trying to solve here?'.