[RFC] Human Readable URLs

Note: We are moving the topics of this forum and it will be deleted at some point

Publish your own request for comments/change or patches for the next version of phpBB. Discuss the contributions and proposals of others. Upcoming releases are 3.2/Rhea and 3.3.
Locked
User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] Human Readable URLs

Post by callumacrae »

This topic is about human readable URLs. It should not be assumed that the human speaks English.
Made by developers, for developers!
My blog

User avatar
sooskriszta
Registered User
Posts: 85
Joined: Wed Dec 29, 2010 7:23 pm

Re: [RFC] Human Readable URLs

Post by sooskriszta »

That's correct, but as long as we aren't all moving to IDNs, they'll have to type understand SOME of the roman alphabet.

Therefore, I'd be fine with something like
http://www.domain.ru/сообщество/topic/Смешные-темы
That being said, it shouldn't be hard at all to implement
http://www.domain.ru/сообщество/тема/Смешные-темы
because тема would really come from the internal translation files of the software...

And therefore any translation of topic (e.g. тема, 主題, หัวข้อ, موضوع, θέμα, etc) should point to the same file/action (viewtopic). Hence, even if topic, forum, etc are shown in default language, it should not create any issue.

The only potential conflict I see is if I installed my phpbb in a directory called тема. But that is easily resolved...most software and languages have some reserved words, and in phpbb, we could include in the instruction that the install directory shouldn't be named x, y, z (3-4 words for each language)
OC2PS
Testfestés, Arcfestés, Csillámfestés

Alapanyagok, Képzések, Ismertetők
Hennafestés
GMAT coaching and MBA Admissions Consulting
formerly known as sooskriszta

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] Human Readable URLs

Post by callumacrae »

But then what if the board language was changed?
Made by developers, for developers!
My blog

User avatar
sooskriszta
Registered User
Posts: 85
Joined: Wed Dec 29, 2010 7:23 pm

Re: [RFC] Human Readable URLs

Post by sooskriszta »

Since

Code: Select all

http://www.domain.ru/сообщество/тема/Смешные-темы
really goes to (for example)

Code: Select all

http://www.domain.ru/сообщество/viewtopic.php?t=40965
and phpbb does't really care whether it is тема or 主題, หัวข้อ, موضوع, θέμα or topic, so
if language is changed (or not changed)

Code: Select all

http://www.domain.ru/сообщество/тема/Смешные-темы
http://www.domain.ru/сообщество/topic/Смешные-темы
http://www.domain.ru/сообщество/主題/Смешные-темы
http://www.domain.ru/сообщество/หัวข้อ/Смешные-темы
http://www.domain.ru/сообщество/موضوع/Смешные-темы
http://www.domain.ru/сообщество/θέμα/Смешные-темы
all go to

Code: Select all

http://www.domain.ru/сообщество/viewtopic.php?t=40965
OC2PS
Testfestés, Arcfestés, Csillámfestés

Alapanyagok, Képzések, Ismertetők
Hennafestés
GMAT coaching and MBA Admissions Consulting
formerly known as sooskriszta

ecwpa
Registered User
Posts: 181
Joined: Mon Jan 24, 2005 2:10 am
Contact:

Re: [RFC] Human Readable URLs

Post by ecwpa »

That could be configurable, even depending of the language since its not relevant for identifyng the IDs.
Slightly better English than it was in 2005, still improving :D

User avatar
naim
Registered User
Posts: 50
Joined: Thu Oct 13, 2011 7:21 pm
Location: Isolation
Contact:

Re: [RFC] Human Readable URLs

Post by naim »

Whats the problem to get the request, look it up on a table, and set the $_GET['f'], $_GET['t'], $_GET['p'] ???

add to index.php:

Code: Select all

<?php

// ...

function lookup($url) {
 // Connect to DB, SELECT forum_id, topic_id FROM phpbb_lookuptable WHERE url=$url;
 // Result with $arr.
return $arr;
}

if (!isset($_GET['f']))
{
  $q = $_GET['q']; // Assuming that ?q=$1 is the rewrite parameter...
  $r = lookup($q);
  $_GET['f'] = $r['forum_id'];
  $_GET['t'] = $r['topic_id'];
}

// ..
SQL for lookup table:

Code: Select all

CREATE TABLE phpbb_lookup (
 url varchar(150) UNIQUE,
 forum_id INT NOT NULL,
 topic_id INT NOT NULL,
 flags INT DEFAULT 0
);
We can define two flags
define("LU_ACTIVE", 0x00); // Active lookup.
define("LU_MOVED", 0x01); // Moved

if (flags & LU_MOVED) {
// Display "redirected/moved" page.
}
// or else it will just continue as it currently is...

So whats the big problem?!

to however was commenting the languages, the nice URL is instead of ?f=24&t=23

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] Human Readable URLs

Post by callumacrae »

It's not quite that simple - for example, request_var (or its replacement by 3.2) should be used instead of $_GET
Made by developers, for developers!
My blog

User avatar
naim
Registered User
Posts: 50
Joined: Thu Oct 13, 2011 7:21 pm
Location: Isolation
Contact:

Re: [RFC] Human Readable URLs

Post by naim »

So change the $q = $_GET['q']; to $q = request_var('q', null);
it is safe to set to $_GET. because we are dealing with numbers.

so it is very simple!
after determining what page is required, all you have to do is require_once 'viewtopic.php';
oh, and about the other pages,
$q = explode("/", request_var('q', null));
if ($q == null) { /* display error message and exit. */ }
else {
switch ($q[0]) {
case "forum": // index.php?q=forum/topic-name-from-any-forum
// set $_GETs
require_once 'viewtopic.php';
break;
case "home":
case default:
break;
}
}

User avatar
Pony99CA
Registered User
Posts: 986
Joined: Sun Feb 08, 2009 2:35 am
Location: Hollister, CA
Contact:

Re: [RFC] Human Readable URLs -- A Simple Proposal

Post by Pony99CA »

I haven't seen an accepted proposal for this. If there was one, I'm sorry -- please link me to it.

I think there's a very simple way to make URLs much more reader-friendly with only minor code changes. I documented this in the phpBB.com topic linked to in the first post, but here's my original proposal: simple user-friendly URLs. To save you guys time, I'll summarize and reformat it here.

Phase 1

I'd be happy if URLs just added the topic title (or post title for post links or forum title for forum links) to the end of the URL.

For example, the URL for the linked topic is:

Code: Select all

http://www.phpbb.com/community/viewtopic.php?f=64&t=2100309
I'd be happy if it were:

Code: Select all

http://www.phpbb.com/community/viewtopic.php?f=64&t=2100309&title=SEF_SEO_URLs
where the &title=SEF_SEO_URLs piece was completely optional/useless. Obviously, any intra-page linking (#text) would have to go after the title attribute. As AmigoJack mentioned, you should also strip leading, trailing and multiple underscores (or hyphens if you prefer those).

Would that be friendly enough for most people? It would be harder to type, so it might not meet the needs for printed material, but I'm not so worried about that. Would it meet the needs of the SEO people? That I don't know.

I think this proposal has several advantages:
  • It's reader-friendly (and maybe more SEO friendly). You can see the title in the link text or when hovering over a text format link.
  • I suspect that could be implemented in very little time, possibly a few hours.
  • It isn't sensitive to changes in the forum/topic/post title because the information is ignored.

Phase 2

To make URLs more typist-friendly, allow the title attribute to have semantics if used alone. For example, if somebody just entered:

Code: Select all

http://www.phpbb.com/community/viewtopic.php?title=SEF_SEO_URLs
you could call the search engine for those words (for topics; forums would need a different search, maybe a SQL query). If only one topic/forum were found, it would be displayed, otherwise the search results would be displayed.

Posts are omitted as there's no viewpost.php. However, if the title attribute were changed to forum-title, topic-title and post-title, you could search for posts and just make the URL like this (for this post):

Code: Select all

http://area51.phpbb.com/phpBB?post-title=RFC_Human_Readable_URLs_A_Simple_Proposal
If a post didn't have a Subject (if that's possible), use the topic title (although that would generate a lot of hits, which will also happen if people use the default Subject in their posts).

That would obviously be more work to implement. That format would also be sensitive to title changes, although possibly less so than other proposals because we're using the search engine.

Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

User avatar
AmigoJack
Registered User
Posts: 110
Joined: Wed May 04, 2011 7:47 pm
Location: グリーン ヒル ゾーン
Contact:

Re: [RFC] Human Readable URLs -- A Simple Proposal

Post by AmigoJack »

Pony99CA wrote:call the search engine for those words
"Humans" might enter URLs with literals as topic identification now and then, which might be filed under "okay". But what about crawlers? I smell a search flood there, not to speak of performance issues. It's a nice idea, but I discourage everyone from associating an identification lookup by text alone.

Also I definitly said this before: handing out URLs with topic titles is already a loss of information control - think of topics in forums that should not be accessible to every user. I.e. this: ;)

Code: Select all

http://www.phpbb.com/community/viewtopic.php?f=64&t=2100309&title=Pony99CA_behaves_oddly_lets_ban_him
Needless to say: this only works with languages using latin characters - what about accents? Ogoneks? Tremas? Or characters from Katakana, Cyrillic, Greek, Hangul...? It should even give English users a little headache as there's no rule what happens to titles like this versus that:

Code: Select all

it's karma
its karma

Locked