If you're interested in user-readable / SEO URLs for phpBB 3.2, look inside.

Do not post support requests, bug reports or feature requests. Discuss phpBB here. Non-phpBB related discussion goes in General Discussion!
Get Involved
Post Reply
shockr
Registered User
Posts: 2
Joined: Tue May 02, 2017 11:52 pm

If you're interested in user-readable / SEO URLs for phpBB 3.2, look inside.

Post by shockr » Sat May 06, 2017 2:34 am

Hey everyone,

I just set up a forum with phpBB 3.2 earlier this week, and I wanted to make the forum and topic URLs user-readable and SEO-friendly. I have read the forum and blog posts about how this doesn't really matter to the search engines anymore, but I figured it'd be a nice to have feature just for readability.

So I decided to make some modifications to the phpBB source files in order to get this to work. Note that this is not in any means the ideal way to do this, especially since if the modified files are affected in a future update, you will have to check and merge, but if you like to live on the edge, keep reading.

Warning/Disclaimer: Proceed with making these changes at your own risk. I am not liable for any damage or harm that may occur to your forum, database, computer or pets from making use of the files provided. Remember to create multiple backups of your files before doing anything.

First, we need to configure the URL rewrite rules.
  • memberlist.php becomes /members
  • memberlist.php?mode=viewprofile&u=2 becomes /members/u2-admin
  • viewforum.php?f=1 becomes /f1-your-first-forum
  • viewtopic.php?t=1&f=1 becomes /f1-your-first-forum/t1-my-topic-title
Define the following Apache rewrite rules (in your .htaccess - included in the archive - or your server configuration file):

Code: Select all

RewriteRule ^members(|/)$ /memberlist.php [QSA,L]
RewriteRule ^members/u(\d+)([a-zA-Z0-9\-_]+)$ /memberlist.php?mode=viewprofile&u=$1 [QSA,L]
RewriteRule ^f(\d+)([a-zA-Z0-9\-]+)/t(\d+)([a-zA-Z0-9\-]+)(.*)$ /viewtopic.php?f=$1&t=$3 [QSA,L]
RewriteRule ^f(\d+)([a-zA-Z0-9\-]+)(.*)$ /viewforum.php?f=$1 [QSA,L]
If you're running nginx, add the following rules to your configuration:

Code: Select all

location /members {
    rewrite ^/members(|/)$ /memberlist.php last;
    rewrite ^/members/u(\d+)([a-zA-Z0-9\-_]+)$ /memberlist.php?mode=viewprofile&u=$1$is_args$args last;
}
location /f {
    rewrite ^/f(\d+)([a-zA-Z0-9\-]+)/t(\d+)([a-zA-Z0-9\-]+)(.*)$ /viewtopic.php?f=$1&t=$3$is_args$args last;
    rewrite ^/f(\d+)([a-zA-Z0-9\-]+)(.*)$ /viewforum.php?f=$1$is_args$args last;
}
Once that's completed, you will need to unpack the zip archive into your phpbb root folder. Remember to backup before extracting the archive. For reference, here's a list of files that will be replaced:

Code: Select all

.htaccess
index.php
memberlist.php
posting.php
search.php
viewforum.php
viewonline.php
viewtopic.php
includes/functions.php
includes/functions_content.php
includes/functions_display.php
includes/functions_posting.php
phpbb/feed/helper.php
To reiterate, this is not an ideal solution, but it works for my purposes. If you would like to see it in action, you can check the phpBB installation I set up at https://www.eresidency.co

You can download the ZIP archive from https://drive.google.com/file/d/0B27L6m ... sp=sharing

Cheers.

.m.
Registered User
Posts: 329
Joined: Wed Nov 04, 2009 8:39 pm

Re: If you're interested in user-readable / SEO URLs for phpBB 3.2, look inside.

Post by .m. » Sun May 07, 2017 4:15 am

this could be useful for some users. Thank You @shockr :)

however not sure that many would attempt it
almost all users like to have officially supported methods ..

also a SEO rewriting URLs extension is in development ..

shockr
Registered User
Posts: 2
Joined: Tue May 02, 2017 11:52 pm

Re: If you're interested in user-readable / SEO URLs for phpBB 3.2, look inside.

Post by shockr » Sun May 07, 2017 8:37 am

Oh yeah, definitely. Like I said, it's not the ideal way to do it, but it's a quick and dirty solution that works well enough, and I just thought I should share since some users may be interested.

koraldon
Registered User
Posts: 483
Joined: Sat Jun 30, 2007 12:42 pm

Re: If you're interested in user-readable / SEO URLs for phpBB 3.2, look inside.

Post by koraldon » Mon May 08, 2017 12:19 pm

Hi,
Looking great - best solution is for you to submit it as a PR to phpbb, so it will be officially included in 3.3.
This will be awesome.

User avatar
Ger
Recognised Extension Developer
Posts: 1792
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: If you're interested in user-readable / SEO URLs for phpBB 3.2, look inside.

Post by Ger » Tue May 09, 2017 6:54 am

koraldon wrote:
Mon May 08, 2017 12:19 pm
submit it as a PR to phpbb, so it will be officially included in 3.3.
I wouldn't count on it.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

koraldon
Registered User
Posts: 483
Joined: Sat Jun 30, 2007 12:42 pm

Re: If you're interested in user-readable / SEO URLs for phpBB 3.2, look inside.

Post by koraldon » Tue May 09, 2017 10:48 am

Ger wrote:
Tue May 09, 2017 6:54 am
koraldon wrote:
Mon May 08, 2017 12:19 pm
submit it as a PR to phpbb, so it will be officially included in 3.3.
I wouldn't count on it.
According to phpbb developers that is the way.
DavidIQ wrote:
Wed Mar 01, 2017 12:07 pm
But this is basically why these SEO discussions never produce any results. It's a lot of talking and arguing and none of the SEO supporters do anything to actually address these grievances. There is a process for getting things added to the core and I can assure you that "exchanging code via PM" is not part of that process. And of course you could say "I can just give you the code over messages for you to do that" except that I know little about SEO nor what the code is supposed to accomplish. I cannot, in good conscience, support or contribute code that I don't understand. If it requires refinements I wouldn't be able to effectively do so.
I'm amazed by the negative attitude to discourage people from contributing to phpbb.

User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 16771
Joined: Thu Jan 06, 2005 1:30 pm
Location: Fishkill, NY
Name: David Colón
Contact:

Re: If you're interested in user-readable / SEO URLs for phpBB 3.2, look inside.

Post by DavidIQ » Tue May 09, 2017 11:53 am

koraldon wrote:
Tue May 09, 2017 10:48 am
I'm amazed by the negative attitude to discourage people from contributing to phpbb.
Exactly the point I was making and what you've just accentuated. ;)
Apply to become a Jr. Extension Validator
My extensions | In need of phpBB services? | Was I helpful today?
No unsolicited PMs unless you're planning on asking for paid help.

User avatar
Derky
Development Team Member
Development Team Member
Posts: 4802
Joined: Sun Apr 10, 2005 9:58 am
Location: Netherlands
Contact:

Re: If you're interested in user-readable / SEO URLs for phpBB 3.2, look inside.

Post by Derky » Tue May 09, 2017 9:36 pm

shockr wrote:
Sat May 06, 2017 2:34 am
You can download the ZIP archive from https://drive.google.com/file/d/0B27L6m ... sp=sharing
Thanks for sharing your code but to all the users of phpBB we however disrecommend using unvalidated code. The recommended way for you is to make it an extension and submit it to the Customisations Database for a (security) review. ;)

Post Reply

Return to “phpBB Discussion”

Who is online

Users browsing this forum: No registered users and 21 guests