View Full Version : Make pretty URLs in my plugin
ub.ch
09-24-2014, 09:45 PM
Heya!
I want to use pretty URLs in my plugin (a marketplace) and can't seem to figure out how vBulletin does it :(
So I have something like this:
/marketplace.php?do=article&id=9
and would like to be
/marktplatz/9-da-vinci-code
so coming from standard PHP with URL parameters, I would like to have a german rewrite (seeing my forum is german), the article ID and the name of the article (in this case the name of the book)
So far the .htaccess is the "easy" way - if I add
RewriteRule ^marktplatz/.* marketplace.php [QSA]
I do see the marketplace.php (but just this one, no parameters used), but now I am sort of stuck on how to tell my plugin to use and parse the new URL structure.
Looking in members.php or other standard vBulletin pages did not seem to help and now I am asking you for any help :)
One (imho ugly) way would be to access $_SERVER['REQUEST_URI'] and parse everything to only give me the ID 9, but this seems a bit over the top.
I am sure there is another way, but I just don't know where to look
Thanks for any help!
Best
Malte
MirKO13
09-24-2014, 10:31 PM
Have you tried "Mod Rewrite Friendly URLs (http://www.vbulletin.com/docs/html/options_seofriendly_urls)" yet?
In Control Panel,Options, Friendly URLs....
Not sure if that's what You're looking for .
Good Luck :)
ub.ch
09-25-2014, 06:48 AM
yes I have - it is turned on in my forum and it works fine.
I am more asking for the technical / code implementation.
So what are available parameters / variables so I can access 9-da-vinci-code or even better have it parsed so I have just the ID
I have found functions like fetch_seo_url(), but they don't seem to help
webmastersun
09-25-2014, 01:51 PM
Enable friend url in control panel, it's enough for you to have friendly URLs on your site :)
ub.ch
09-25-2014, 06:38 PM
I am not sure if I am making myself clear: I do know how to enable enable it. It is already in use. My question is, how do I as adeveloper make use of the feature in my own self coded plugin
MirKO13
09-25-2014, 09:52 PM
Have You tried any SEO software yet? Like DragonByte SEO (https://vborg.vbsupport.ru/showthread.php?t=308615&page=33)?.
AddOn Support
Allows other modifications to add their own rewrite rules / sitemap integration
cellarius
09-26-2014, 04:01 PM
Neither of the suggestions up to now will help him. He has no issues with friendly URLs in his forum. He has coded an addon, and he wants to hook that addon into the vB friendly URL system. He wants to make the URLs that his addon creates to be friendly.
I can't immediately help with the issue at hand, but more suggestions to get vB's friendly URLs running or buy expensive addons won't help him ;)
Lynne
09-26-2014, 04:16 PM
Take a look at the function fetch_seo_url
https://members.vbulletin.com/api/vBulletin/_includes---functions.php.html#functionfetch_seo_url
ub.ch
09-26-2014, 04:25 PM
Neither of the suggestions up to now will help him. He has no issues with friendly URLs in his forum. He has coded an addon, and he wants to hook that addon into the vB friendly URL system. He wants to make the URLs that his addon creates to be friendly.
I can't immediately help with the issue at hand, but more suggestions to get vB's friendly URLs running or buy expensive addons won't help him ;)
Thanks :)
I was starting to think I am not explaining myself clear enough
Take a look at the function fetch_seo_url
https://members.vbulletin.com/api/vBulletin/_includes---functions.php.html#functionfetch_seo_url
Thanks! But as mentioned in a post above I have already stumbled upon this function.
As far as I understand this is to generate a SEO URL but not parse an existing one :/
But I just found this thread https://vborg.vbsupport.ru/showthread.php?t=241364
(funny, earlier searches did show only good results...)
I'll read into this and keep you posted!
cellarius
09-26-2014, 04:30 PM
But your problem is about generating one. You need to generate it whenever you link to pages of your addon.
Parsing does not happen in vB. That happens in .htaccess. You need an .htaccess entry that changes
/marktplatz/9-da-vinci-code
back to
/marketplace.php?do=article&id=9
Look at vB4's existing .htaccess file to get inspiration.
Edit: OK, rereading your post, you already know that and are explicitly asking for that :) But don't forget: the htaccess alone will not suffice - you also need to properly generate the URLs in vB. I am, however, not sure what a "german rewrite" exactly means...
Anyway, rewriting as you wish seems problematic, since you have two parameters in your standard URL, but only one in the friendly one.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.