View Full Version : Miscellaneous Hacks - Custom SEO urls (mod_rewrite only)
Carnage
12-28-2009, 10:00 PM
What does this do?
This mod allows you to define the beginning part of all the friendly urls. Eventually, more of the url may be customizable but this should be enough to provide a nice structure to your site anyway. I have now released this as more of a mod to make it easier for the less technical admins.
What use is this to me?
I can see a couple of major uses here.
1. If you want to translate the friendly urls into your local language (so instead of having http://example.com/threads/123-Test-Thread/ you have http://example.com/[translation]/123-Test-thread)
2. You want a bit more structure to your links eg forum/threads, forum/posts, blogs/entries etc
3. You just don't like the defaults you've been stuck with and want to change to t,p,f,b and e
Installation
1. First step here, is to ensure that the default mod rewrite urls work for you. Upload the default .htaccess file from the do_not_upload folder to your forums and switch on mod rewrite friendly urls in the server settings and optimisations area of your control panel.
2.Browse around your forums and check that all the links still work. (If they don't you need to work with vb support and your host to get them working)
3. Upload the contents of the upload folder in the zip.
4. Import the product.
5. There is now a new option group in your admin cp; friendly url settings. Change these to your liking.
5a. There is also a link to the rewrite rule generator from the settings page; once you've got the settings to your liking, visit the link to generate a .htaccess file. Alternativly follow the instructions below to make your own.
6. Once you've made these changes, you need to edit your .htaccess file rewrite rules to reflect the changes you made. You need to replicate the change to this file that you've made to the options. you will see a set of:
RewriteRule ^threads/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) showthread.php?t=$1&page=$2&%{QUERY_STRING}
RewriteRule ^members/([0-9]+) member.php?u=$1&%{QUERY_STRING}
RewriteRule ^forums/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) forumdisplay.php?f=$1&page=$2&%{QUERY_STRING}
RewriteRule ^blogs/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) blog.php?u=$1&page=$2&%{QUERY_STRING}
RewriteRule ^entries/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) entry.php?b=$1&page=$2&%{QUERY_STRING}
You need to change the red bits to match your settings.
7. (Optional) Extra credit. Some people want the /forums/ to point to the forumindex page and /blogs/ to point to blog.php the following rewrite rules will take care of this. These should be added to the .htaccess file (don't overwrite any existing rules, these are new ones)
RewriteRule ^forums/(index.php)?$ forum.php?%{QUERY_STRING}
RewriteRule ^blogs/(index.php)?$ blog.php?%{QUERY_STRING}
Finally do a search of your templates + phrases for occurrences of forum.php and blog.php and change them to forums/index.php and blogs/index.php (or forums/ and blogs/) respectively.
forums.domain.com and blogs.domain.com support
This is not quite as easy as the above and requires a file edit to achieve.
If you are using 4.0.1; you can skip the file edit part as it appears to work without.
1. Make a backup copy of includes/class_friendly_url.php
2. Around line 604 find:
// REQUEST_URI is dependable for apache
if (isset($_SERVER['REQUEST_URI']))
{
// return the raw url
$url = $_SERVER['REQUEST_URI'];
$url = $this->registry->input->strip_sessionhash($url);
return $url;
}
Replace
$url = $_SERVER['REQUEST_URI'];
with
$url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
3. In your apache config or appropriate server config file, set a serveralias for the subdomains you want to use (eg forums.domain.com) You may need to contact your host for help with this step.
4. In the vbulletin control panel set the cookie domain to be .yourdomain.com
I dont know if this will have any knock on effects elsewhere, but it seems to be working for me on my dev board.
5. You can now set a value for forums to be http://forums.domain.com and blogs to be http://blogs.domain.com or similar based upon your requirement.
6. Rewrite rules are a bit more complex for this setup; this is a good resource for getting the server side stuff setup: http://www.reconn.us/content/view/46/67/
example rewrite rules:
RewriteCond %{HTTP_HOST} ^(www.)?forums.domain.com$ [NC]
RewriteRule ^threads/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) showthread.php?t=$1&page=$2&%{QUERY_STRING}
RewriteRule ^members/([0-9]+) member.php?u=$1&%{QUERY_STRING}
RewriteRule ^/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) forumdisplay.php?f=$1&page=$2&%{QUERY_STRING}
RewriteRule ^/(index.php)?$ forum.php?%{QUERY_STRING}
RewriteCond %{HTTP_HOST} ^(www.)?blogs.domain.com$ [NC]
RewriteRule ^entries/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) entry.php?b=$1&page=$2&%{QUERY_STRING}
RewriteRule ^/(index.php)?$ blog.php?%{QUERY_STRING}
RewriteRule ^/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) blog.php?u=$1&page=$2&%{QUERY_STRING}
Changelog
4.0-0.1 a4
Added file to generate rewrite rules
Removed old instructions from this post to prevent confusion.
4.0-0.1 a3
Fixed missing settings in product file.
4.0-0.1 a2
Released as product
4.0-0.1 a1
Initial release
Notes
forums.domain.com and blogs.domain.com is possible, but requires a file edit; Instructions above)
adding extra information to urls is /not/ currently possible (eg tags, forum name to threads etc)
if you want a custom url format, post what you would like and if its possible, I can give you more pointers on how to implement it.
if you change your url format, you may want to leave the old rewrite rules in making a copy of them instead of editing them.
if you want the old instructions, for manual file edits (advanced users only) pm me.
There is some experimental code now attached, this provides an example of how to create custom uri formats (includes forum name in thread urls) but is no where near finished and is for advanced users (read coders) only. This functionality will be built into the product once its been tested and is more stable.
Charlie98902
12-29-2009, 03:11 PM
Tagged for future use.
BSMedia
12-29-2009, 04:21 PM
This seems to be more of an article ;)
But useful information none the less!
Zaiaku
12-29-2009, 04:29 PM
This seems to be more of an article ;)
But useful information none the less!
I kind of have to agree with it. At first that's what I thought this was.
rtyagis
12-29-2009, 05:08 PM
Good Mod. Waiting for live demo.:up:
Carnage
12-29-2009, 05:19 PM
This seems to be more of an article ;)
But useful information none the less!
Right now it is it may become a mod when the options are settable from the admin cp: I looked at how to do this with hooks/plugins and its a mess... I came up with a better way which requires file edits; but they are so trivial I submitted them as a patch to vb. Once I get feedback on the chances of getting the patch included in 4.0.x I'll know if its worth developing this into a full mod.
Ryan Ashbrook
12-29-2009, 05:58 PM
Tagged. :)
Alfa1
12-29-2009, 06:24 PM
Do you plan to add forums.domain.com in the future? I would be extremely happy if you do.
Carnage
12-29-2009, 10:35 PM
I'm not sure if its possible; however I have an idea how it might be possible to get it to work.
Edit:
Tested my idea; it is at least in theory possible to have forums.example.com; if you set the path to http://forums.yourdomain.com/threads (for threads) the urls will be correct; but i've not idea how to get the rewrites working for it...
I see this as an article, too. Nevertheless it's tagged for future use ;)
Carnage
12-30-2009, 01:11 AM
ok; it is doable, however theres an aditional edit that needs to be made around line 604 find:
// REQUEST_URI is dependable for apache
if (isset($_SERVER['REQUEST_URI']))
{
// return the raw url
$url = $_SERVER['REQUEST_URI'];
$url = $this->registry->input->strip_sessionhash($url);
return $url;
}
Replace
$url = $_SERVER['REQUEST_URI'];
with
$url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
I dont know if this will have any knock on effects elsewhere, but it seems to be working for me on my dev board. You'll need to set a server alias for forums.yourdomain.com to be the same as yourdomain.com in apache and you'll also need to edit the cookie path domain to cover your entire domain (eg set it to .yourdomain.com). Once you've done this, if you set threads to http://forums.yourdomain.com/threads and forums to http://forums.yourdomain.com with a bit of tweaking, you should be able to get it right.
Carnage
01-06-2010, 04:17 PM
I've updated the first post with a product and uploadable file which will allow customisations from the admincp (without requiring file edits to vbulletin php files)
Charlie98902
01-06-2010, 04:53 PM
Great work looks easy and just waiting on the bugs to be worked out.
Carnage
01-07-2010, 12:05 PM
You could always assist with that process by installing it in a development enviroment and seeing if you can find some bugs :P
Charlie98902
01-07-2010, 01:12 PM
Oops re-read and the default mod rewrite won't work as I get the 500 errors right now.
Carnage
01-07-2010, 06:17 PM
What version of apache are you running?
Shai Gar
01-13-2010, 08:26 PM
does this work with 4.0.1 as i don't seem to see any new options in the and admincp when i install the product
Carnage
01-13-2010, 10:22 PM
The options are listed under settings -> options -> Friendly URL settings.
winstone
01-13-2010, 11:34 PM
The options are listed under settings -> options -> Friendly URL settings.
I can't find it
Carnage
01-14-2010, 10:46 AM
For some reason, the settings fields were missing from the product file :S the phrases for them were there but the options themselves weren't...
Please try the latest version, alpha 3 and see if the settings now appear.
winstone
01-14-2010, 12:18 PM
Options are there now and it works great,
by the way the settings menu is called "Custom Friendly URL Settings" (link: YOURDOMAIN/admincp/options.php?do=options&dogroup=imhotek_custom_urls_settinggroup)
Thanks
Shai Gar
01-14-2010, 04:27 PM
thanks for the update, but trying to get subdomains working and can't find the code to edit in class_friendly_url.php
Carnage
01-14-2010, 05:12 PM
Checklist:
1. Are you editing the file that came with vb (the file that this mod ships with is called class_custom_friendly_url.php and is not the one you need to edit :))
2. Try using your text editor's find function the text sting ' // REQUEST_URI is dependable for apache' only appears once in the file and is a couple of lines above the one you need to edit.
3. Its possible that vb4.0.1 has something slightly different there; once I upgrade later this evening i'll check this.
mescalin
01-14-2010, 05:36 PM
its a good idea to have a custom seo urls. Can we create custom urls such as sitename.com/thread-title-threadid.html as vbseo offers?
Carnage
01-14-2010, 05:58 PM
There aren't enough hooks in the friendly url class to achieve that much customisation at the moment.
@shai gar: I've just upgraded my board to 4.0.1; they've changed a good deal of code in class_friendly_url.php It seems the file edit isn't required now. Try following the instructions without making the file edit and see if it works (It worked fine on my dev board without)
Gnoll
01-14-2010, 07:53 PM
thank you :) looks cute , works cute , it is cute
Carnage
01-15-2010, 10:50 AM
its a good idea to have a custom seo urls. Can we create custom urls such as sitename.com/thread-title-threadid.html as vbseo offers?
Good news; while updating myself on the changes made in 4.0.1; I've discovered a way to do this elegantly. I could give you the code but it also requires you to be a regex wizard to get the rewrite rules working. (Took me 20 mins and i'm quite good with them) My next feature i'm intending to add to this product is an automatic generator for the rewrite rules. Once i've got that working, i'll see about adding aditional customisations.
winstone
01-15-2010, 11:59 AM
Please also consider adding categoryTitle to thread links, something like domain.com/categoryTitle-id/threadTitle-id
cloferba
01-15-2010, 12:10 PM
how can i let default vbseo urls..on vb4 without using vbseo?
Carnage
01-15-2010, 12:40 PM
@winstone:
Currently I can achieve that for forums + subforums only. Doing it for threads, appears to need a database query. Which is just unacceptable considering the number of urls a typical page builds.
@cloferba:
What are the default vbSEO links?
Mukashi
01-15-2010, 06:00 PM
I know this one might be a bit of a long shot, but would there be some way to set things up so that each category on the CMS could itself go on a separate subdomain, so we could do things like splitting up news and content sections?
Carnage
01-15-2010, 11:29 PM
@mukashi: Not with the current version; i've not really touched upon how to customise cms urls as they are handled differently from forum urls. It's something i'll probably look at in the future however.
I've been playing around with whats possible. Currently i've managed to flip the id and the title around sucessfully. As well as including the forum name in the url for threads. I'm hoping to bring quite a bit of customisation in the future for forum urls.
Carnage
01-16-2010, 03:40 PM
Added a file to the zip which gets uploaded to the admincp. This file does a best guess generation of rewrite rules for you.
trying to get working with subdomain.domain.com
but i have a problem with this step:
5. You can now set a value for forums to be http://forums.domain.com and blogs to be http://blogs.domain.com or similar based upon your requirement.
setting it (site name/url/contact details) changes whole vbulletins default domain. help? i want to open home with domain.com and forums with subdomain
winstone
01-18-2010, 10:32 PM
@winstone:
Currently I can achieve that for forums + subforums only. Doing it for threads, appears to need a database query. Which is just unacceptable considering the number of urls a typical page builds.
not if you modify the db query that gets the thread data :D
I know it's a lot of work and there are other ways to do it as well, maybe by checking all the cached templates and rewriting all matched urls is easier, in any case i'll defiantly do this or might give up n go with vbseo even tho its a rip off (IMO)
Carnage
01-19-2010, 09:43 AM
setting it (site name/url/contact details) changes whole vbulletins default domain. help? i want to open home with domain.com and forums with subdomain
You need to change the setting in the friendly url settings. If you change the setting for threads to http://forums.domain.com/threads and the forums friendly url to http://forums.domain.com/index.php it should work.
not if you modify the db query that gets the thread data
The problem isn't that the data isn't avalaible anywhere, its that its not avaliable within the part of the code that forms the url. I've been experimenting, I've managed to save and retrieve the data in most important places (eg forum display, forum home, thread display etc) but not everywhere. It needs a bit more work yet still leaves some dead urls around the place... (vb's fault for not using {vb:link ...} everywhere a link is made)
I know it's a lot of work and there are other ways to do it as well, maybe by checking all the cached templates and rewriting all matched urls is easier, in any case i'll defiantly do this or might give up n go with vbseo even tho its a rip off (IMO)
vbSeo does a few thigns this can't, but most people jsut want customisable urls, so for them it is a rip off. Rewriting templates or output is one way to do it but its ugly, bug prone and inefficient.
Coder
You are marked on here as a coder, so I assume this means you've release at least one mod implying that you understand php. I'll upload the code i've been working on for threads and you can give it a go, be aware though, you will need to create your own rewrite rules and edit the code to change the url structure.
it's possible to replace forums ids with names?
for example:
domain.com/forums/10
to: domain.com/forums/off-topic
Gnoll
01-19-2010, 10:30 AM
hmm looks nice /threads/forum/topic
can we rewrite it as /forum-f<id>/topic-t<id>.html ? or /forum/<id>-topic
winstone
01-19-2010, 10:33 AM
You are marked on here as a coder, so I assume this means you've release at least one mod implying that you understand php. I'll upload the code i've been working on for threads and you can give it a go, be aware though, you will need to create your own rewrite rules and edit the code to change the url structure.
I've only released some javascript based mod but actually I only code in PHP
Thanks for sharing your thoughts and the code, I haven't started on working on URL rewrites and SEO yet but I will soon
VB should have used one single router and one single method to create links, but what's been released is a mess. I call vbSEO rip off when comparing it with other community softwares out there which provide very good SEO tools for free and the cost for vbSEO is almost the same as what you would pay to buy those softwares, otherwise I'm not questioning it's functionalities
Carnage
01-19-2010, 11:48 AM
it's possible to replace forums ids with names?
That one isn't easilly possible, the id needs to be avaliable somewhere for vb to use to query the db with.
can we rewrite it as /forum-f<id>/topic-t<id>.html ? or /forum/<id>-topic
If you are confidant with php, you can take a look at the contents of the experimental zip files I uploaded; otherwise you will have to wait until that code is stable and included in the product.
should have used one single router and one single method to create links, but what's been released is a mess.
I suspect that this will be the case once the rewrite is completed eg by 4.2/4.3 but for 4.0.x we have to cope with the mess thats been made.
I call vbSEO rip off when comparing it with other community softwares out there which provide very good SEO tools for free and the cost for vbSEO is almost the same as what you would pay to buy those softwares, otherwise I'm not questioning it's functionalities
I agree with this fully, especially when you consider it used to cost $150 even when vbulleitn was only $160 to buy. If it were $50 I immagine it'd be installed on pretty much every vbulletin board (except the official ones of cause :p)
I almost wonder if IB have got some deal with vbSEO not to kill them off; it took so long to get friendly urls in the core package and even with them in there, the functionallity is so lacking. While developing this i've been constantly amased at how easy it was to get most functionlity working. To get it working perfectly requires a few file edits, but vb could have made them.
I intend to keep making improvments to this product including the amount of customisation avaliable and hopefully expanding to other areas eg the CMS untill vb improve the friendly urls in the core product.
Skyrider
01-19-2010, 12:29 PM
This is a really nice plugin, that's for sure.. But I have a small issue. As soon as I alter the links, the previous SEO URL will give a 404 / dead link. Anyway possible that the old SEO (For example, the RewriteRule ^forums/ can be "forward" to the new url without touching the whole link? So the whole link from:
www.xxx.com/forums/34-test to www.xxx.com/sections/34-test will merely forward forums to sections without touching the whole link together.
Second, is it also possible to get rid of the whole "forums"? so instead of:
www.xxx.com/forums/34-test
It will show:
www.xxx.com/34-test
Carnage
01-19-2010, 01:34 PM
if you change your url format, you may want to leave the old rewrite rules in making a copy of them instead of editing them.
From the notes, i mentioned this. Essentially if you do that (and your old rules are compatible with the new ones) vb will redirect to the correct url.
For your second question; i've not tried every possible combination of rewrites; but that one should work.
That one isn't easilly possible, the id needs to be avaliable somewhere for vb to use to query the db with.
so just leave the id and add the name
domain.com/forums/10-off-topic
or something like this.
Brandon Sheley
01-19-2010, 03:05 PM
will this work with a sitemap?
if not, than I don't find it useful ?
Carnage
01-19-2010, 04:51 PM
so just leave the id and add the name
domain.com/forums/10-off-topic
Thats the default setting without installing this mod. If you have your forums installed in forums however, setting the forums prefix to be blank will probably do this. (If you get a // in the url set it to http://www.domain.com/forums instead)
will this work with a sitemap?
if not, than I don't find it useful ?
Ive not tested it with the site map; I assume that the sitemap uses the get_friendly_url() function thou, provided it does, then this will work with the sitemap.
i get this error:
No thread specified. If you followed a valid link, please notify the administrator (http://www.forumivirtual.com/sendmessage.php)
but link is in this mode:
/showthread.php?Prshndetje-dhe-Urime/KiSs-8111
Carnage
01-23-2010, 06:09 PM
@WxP
1. It seems you are using the experimental code to create links. You need to create your own rewrite rules for this to work. It's also experimental if you can't get it working on your own, you will have to wait untill I've got the code more stable and included it in the main product.
2. You don't have the friendly urls set to mod_rewrite. This mod only works if you use that setting.
3. I'm guessing here but if you put the id right at the front of the url (eg before even the forum) it /might/ work as you've got it setup. eg:
/showthread.php?8111-Prshndetje-dhe-Urime/KiSs
Carnage
01-26-2010, 10:25 AM
Added a screenshot of the options provided by this mod.
i do all this you can check!
i put this code in .htaccess
#Credits: Christopher Riley, Vbulletin, http://www.vbulletin.com/forum/showthread.php?325798
#File was made with the best bits from all the above.
#turn on and setup rewrite engine
RewriteEngine On
Options +FollowSymLinks
### THIS IS A LITTLE EXTRA SECURITY AND CAN BE REMOVED
#Has to be at the top else it wouldn't get past the accident prevention rules
RewriteRule ^includes/(.*) index.php
RewriteRule ^vb/(.*) index.php
RewriteRule ^packages/(.*) index.php
#Prevent rewriting files; this will/should stop accidentilly hiding images/js etc from the browser
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
#these rules can't be edited by my mod, so leave them as are.
RewriteRule ^content/(.*) content.php?r=$1&%{QUERY_STRING}
RewriteRule ^widget/config/([0-9]+) widget.php?r=config/$1&%{QUERY_STRING}
RewriteRule ^list/([^/]*/)([0-9]+) list.php?r=$1$2&%{QUERY_STRING}
RewriteRule ^/threads/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) showthread.php?t=$1&page=$2&%{QUERY_STRING}
RewriteRule ^members/([0-9]+) member.php?t=$1&%{QUERY_STRING}
RewriteRule ^blogs/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) blog.php?u=$1&page=$2&%{QUERY_STRING}
RewriteRule ^forums/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) forumdisplay.php?f=$1&page=$2&%{QUERY_STRING}
RewriteRule ^entries/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) entry.php?b=$1&page=$2&%{QUERY_STRING}
#You can remove the # in front of one of these rules to rewrite blogs/ or blogs/index.php to blogs.php
#(sorry i've no way to automatically detect If you are likely to need this or not)
#RewriteRule ^blogs/(index.php)$ forum.php?%{QUERY_STRING}
#RewriteRule ^blogs/index.php$ forum.php?%{QUERY_STRING}
Carnage
01-27-2010, 09:32 AM
RewriteRule ^/threads/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) showthread.php?t=$1&page=$2&%{QUERY_STRING}
should be
RewriteRule ^threads/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) showthread.php?t=$1&page=$2&%{QUERY_STRING}
Thats either a bug in my script, or you put a / at the beggining of your threads setting
I have trying /threads/ /threads threads/ Not working :(
Carnage
01-27-2010, 03:01 PM
#Credits: Christopher Riley, Vbulletin, http://www.vbulletin.com/forum/showthread.php?325798
#File was made with the best bits from all the above.
#turn on and setup rewrite engine
RewriteEngine On
Options +FollowSymLinks
### THIS IS A LITTLE EXTRA SECURITY AND CAN BE REMOVED
#Has to be at the top else it wouldn't get past the accident prevention rules
RewriteRule ^includes/(.*) index.php
RewriteRule ^vb/(.*) index.php
RewriteRule ^packages/(.*) index.php
#Prevent rewriting files; this will/should stop accidentilly hiding images/js etc from the browser
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
#these rules can't be edited by my mod, so leave them as are.
RewriteRule ^content/(.*) content.php?r=$1&%{QUERY_STRING}
RewriteRule ^widget/config/([0-9]+) widget.php?r=config/$1&%{QUERY_STRING}
RewriteRule ^list/([^/]*/)([0-9]+) list.php?r=$1$2&%{QUERY_STRING}
RewriteRule ^threads/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) showthread.php?t=$1&page=$2&%{QUERY_STRING}
RewriteRule ^forums/index.php$ forum.php?%{QUERY_STRING}
#Place a # in front of the above rule and remove the # from the below rule if you want to make index.php optional in the url
#RewriteRule ^forums/(index.php)$ forum.php?%{QUERY_STRING}
RewriteRule ^members/([0-9]+) member.php?t=$1&%{QUERY_STRING}
RewriteRule ^blogs/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) blog.php?u=$1&page=$2&%{QUERY_STRING}
RewriteRule ^forums/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) forumdisplay.php?f=$1&page=$2&%{QUERY_STRING}
RewriteRule ^entries/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) entry.php?b=$1&page=$2&%{QUERY_STRING}
#You can remove the # in front of one of these rules to rewrite blogs/ or blogs/index.php to blogs.php
#(sorry i've no way to automatically detect If you are likely to need this or not)
#RewriteRule ^blogs/(index.php)$ forum.php?%{QUERY_STRING}
#RewriteRule ^blogs/index.php$ forum.php?%{QUERY_STRING}
Thats what I get out of the rewrites script when using the same settings as you have.
Bear in mind, you need to SAVE the settings before the rewrite script will give you upto date results.
Thank you, All installet but addons dont have chans with my script!
Plugin is on you can check www.forumivirtual.com if it work!
Carnage
01-27-2010, 07:13 PM
You need to have mod_rewrite urls switched on.
Hammertime
03-03-2010, 10:38 AM
If I try to view forums as guest I get a 404 Not found error with the url being www.mydomain.com/forum/forumtitle. When I log in, I can get to forum as the url changes to www.mydomain.com/forum/forum/forumtitle
Any idea what is wrong?
Carnage
03-03-2010, 11:37 AM
I think this is a known bug in vbulletin; thou I thought it had been fixed...
Edit: was correct see http://www.vbulletin.com/forum/project.php?issueid=35139
If you change the forums prefix to something other than forum eg f or forums, it should work correctly.
Hammertime
03-03-2010, 11:56 AM
I think this is a known bug in vbulletin; thou I thought it had been fixed...
Edit: was correct see http://www.vbulletin.com/forum/project.php?issueid=35139
If you change the forums prefix to something other than forum eg f or forums, it should work correctly.
Thanks for quick reply mate. Yeah I changed the prefix to f and it's working.
Is there any way to have it domain.com/forum/title rather than domain.com/forum/f/2-title? Or even a way to just remove the forum id?
Carnage
03-03-2010, 03:22 PM
You can't remove the forumid - vb needs that to know which forum to show :p As for removing the 'f/' Its doable, however the more you mess around with the internals of the rewriting the more issues arise from it.
I have a really nice bit of code that rewrites threads to be /forums/forum-title/subforum-title/thread-title-threadid as elegant as it was, it required lots of little adjustments here and there to have it work properly.
3bir.com
03-04-2010, 01:24 PM
can i customize it like That
::thread::
http://v.3bir.com/1/
page 2
http://v.3bir.com/1-2/
::Forums::
http://v.3bir.com/f14/
page 2
http://v.3bir.com/f14-2/
::Members::
http://v.3bir.com/m1/
Carnage
03-04-2010, 08:59 PM
This mod allows for simple customisations only; as it relies on vbulletins own rewriting classes. The more you try to customise, the more likely it is that you will have knock on effects else where.
Once vbulletin is a bit more stable and its unlikely that the url classes will change too much between versions, at that point i'll look into other things that can be achieved.
3bir.com
03-04-2010, 09:07 PM
Thank you Carnage
kristinprimal
03-30-2010, 05:03 PM
This is working great for me up to a point, but what I'd really like now is a way to remove the forum number in the friendly URL.
i.e., right now it is showing:
http://mydomain.com/forums/forum/1234-the-forum-title
and I'd like it to just say:
http://mydomain.com/forums/forum/the-forum-title
Anyone know a way to do this? It doesn't have to be part of the product, if someone can tell me what .php file to change and where, and what to put in .htaccess, that would work for me too.
thanks very much~
Carnage
03-31-2010, 02:56 PM
can't do that unfortunatly. Vb needs the number in order to identify which forum/thread is being accessed.
yellowpinky
04-03-2010, 02:59 PM
can't do that unfortunatly. Vb needs the number in order to identify which forum/thread is being accessed.
There is a product vbSEO which changes the vb member url
from:
http://mydomain.com/members/1234-UserName
to:
http://mydomain.com/members/UserName
Getting rid of the user number.
There is underlying code already there to work without the number.
http://mydomain.com/member.php?username=UserName
What would be needed is a similar change to forum.php to process parameter
forumname=ForumName
Then comes the corner case that ForumName is not a unique key.
vbSEO handles this by moving the forumid to the other side of the slash.
from:
http://mydomain.com/forum/1234-the-forum-title
to:
http://mydomain.com/f1234/the-forum-title
yellowpinky
04-03-2010, 03:19 PM
This is excellent stuff!
What/Where is necessary to change to enable..
from:
http://mydomain.com/album.php?u=1234
to:
http://mydomain.com/members/UserName/albums
Then from:
http://mydomain.com/album.php?albumid=345
to:
http://mydomain.com/members/UserName/albums/AlbumName
Finally from:
http://mydomain.com/album.php?albumid=345&attachmentid=456
to:
http://mydomain.com/members/UserName/albums/AlbumName/456-PictureName
?
Carnage
04-04-2010, 01:42 AM
The member one might be doable then, however you already identified the issue with doing the same for forum names and thread titles -> the titles are not unique.
As for moving the forumid to the other side of the slash, take a look at the code in the experimental zip i uploaded; there is at lease one example in there that shows how to do things like that. (your url would probably end up as forums/1234/forum-title thou; this can be changed but requires substantially more work)
album rewriting is not supported at all by vbulletin atm, I'm personally hoping that this is because they plan to give albums a major overhaul in 4.1 so didn't bother changing anything in 4.0
Fr4n-FX
05-03-2010, 09:19 PM
i have a problem, when i write blog.xxxx.net this is the main forum, no blog.php
this is my htaccess:
RewriteRule ^threads/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) showthread.php?t=$1&page=$2&%{QUERY_STRING}
RewriteRule ^members/([0-9]+) member.php?u=$1&%{QUERY_STRING}
RewriteRule ^forums/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) forumdisplay.php?f=$1&page=$2&%{QUERY_STRING}
RewriteRule ^blogs/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) blog.php?u=$1&page=$2&%{QUERY_STRING}
RewriteRule ^entries/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) entry.php?b=$1&page=$2&%{QUERY_STRING}
RewriteRule ^list/([^/]*/)([0-9]+) list.php?r=$1$2&%{QUERY_STRING}
RewriteRule ^content/(.*) content.php?r=$1&%{QUERY_STRING}
RewriteRule ^widget/config/([0-9]+) widget.php?r=config/$1&%{QUERY_STRING}
RewriteCond %{HTTP_HOST} ^(www.)?forum.xxxx.net$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?blog.xxxx.net$ [NC]
RewriteRule ^/(index.php)?$ blog.php?%{QUERY_STRING}
RewriteRule ^/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) blog.php?u=$1&page=$2&%{QUERY_STRING}
RewriteRule ^forums/(index.php)?$ forum.php?%{QUERY_STRING}
RewriteRule ^blogs/(index.php)?$ blog.php?%{QUERY_STRING}
any idea?
also i need to edit this:
http://www.vbulletin.com/forum/project.php?issueid=37477
in my template, for relative path url changes :/
Carnage
05-04-2010, 12:11 PM
Just a brief look at your htaccess, i think its somewhat wrong. Try this instead:
RewriteCond %{HTTP_HOST} ^(www.)?forum.xxxx.net$ [NC]
RewriteRule ^threads/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) showthread.php?t=$1&page=$2&%{QUERY_STRING}
RewriteRule ^members/([0-9]+) member.php?u=$1&%{QUERY_STRING}
RewriteRule ^forums/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) forumdisplay.php?f=$1&page=$2&%{QUERY_STRING}
RewriteRule ^list/([^/]*/)([0-9]+) list.php?r=$1$2&%{QUERY_STRING}
RewriteRule ^content/(.*) content.php?r=$1&%{QUERY_STRING}
RewriteRule ^widget/config/([0-9]+) widget.php?r=config/$1&%{QUERY_STRING}
RewriteCond %{HTTP_HOST} ^(www.)?blog.xxxx.net$ [NC]
RewriteRule ^/(index.php)?$ blog.php?%{QUERY_STRING}
RewriteRule ^/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) blog.php?u=$1&page=$2&%{QUERY_STRING}
RewriteRule ^forums/(index.php)?$ forum.php?%{QUERY_STRING}
RewriteRule ^blogs/(index.php)?$ blog.php?%{QUERY_STRING}
frmessages
05-15-2010, 11:09 AM
Hi there, thanks for this add-on which seems to solve some of the mess i had with the default URLs.
I keep getting one problem and maybe it could be solved by editing rewrites or something else along this mod ?
My Unregistered user is being redirected from http://www.example.com to http://www.example.com/content/
In fact the "Home section" leads to this /content/ whereas i would like it to be clean (root).
Which basically means i have no canonical URL to share.
The only place i can see i could edit is here but it says "leave them as are":
#these rules can't be edited by my mod, so leave them as are.
RewriteRule ^content/(.*) content.php?r=$1&%{QUERY_STRING}
RewriteRule ^widget/config/([0-9]+) widget.php?r=config/$1&%{QUERY_STRING}
RewriteRule ^list/([^/]*/)([0-9]+) list.php?r=$1$2&%{QUERY_STRING}
Or maybe there is something i should add to .htaccess at root ?
Any idea ? Thanks for your attention and keep up the good work :up:
Carnage
05-15-2010, 01:29 PM
Unfortunatly, I've not yet figured out a clean way of editing the urls generated by the CMS; it seems to require a huge amount of editing of php files to get anywhere.
As for your other problem; I've got that set to work on my development board, but I don't remember how :s What are the values for the settings CMS url and default page under content management?
frmessages
05-15-2010, 02:06 PM
Thanks for your answer.
I have these settings :
CMS url :
/
Default page :
1-Index
CMS url in tabs :
/
And my htaccess in root looks like that (the rules for showthread, member, blog etc. work)
RewriteEngine on
# If you are having problems or are using VirtualDocumentRoot, uncomment this line and set it to your vBulletin directory.
# RewriteBase /forum/
RewriteCond %{HTTP_HOST} !^www.example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# Forum
RewriteRule ^voyage/.* showthread.php [QSA]
RewriteRule ^forums/.* forumdisplay.php [QSA]
RewriteRule ^membres/.* member.php [QSA]
RewriteRule ^blogs/.* blog.php [QSA]
ReWriteRule ^billet/.* entry.php [QSA]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# MVC
RewriteRule ^(?:(.*?)(?:/|$))(.*|$)$ $1.php?r=$2 [QSA]
frmessages
05-15-2010, 02:10 PM
Thanks for your answer.
I have these settings :
CMS url :
/
Default page :
1-Index
CMS url in tabs :
/
And my htaccess in root looks like that (the rules for showthread, member, blog etc. work)
RewriteEngine on
# If you are having problems or are using VirtualDocumentRoot, uncomment this line and set it to your vBulletin directory.
# RewriteBase /forum/
RewriteCond %{HTTP_HOST} !^www.example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# Forum
RewriteRule ^thread/.* showthread.php [QSA]
RewriteRule ^forums/.* forumdisplay.php [QSA]
RewriteRule ^membres/.* member.php [QSA]
RewriteRule ^blogs/.* blog.php [QSA]
ReWriteRule ^billet/.* entry.php [QSA]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# MVC
RewriteRule ^(?:(.*?)(?:/|$))(.*|$)$ $1.php?r=$2 [QSA]
Carnage
05-16-2010, 09:52 AM
My settings differ from yours in that my cms url and cms url in tabs is set blank not to /; thats the only differance I can see that might make a change.
frmessages
05-17-2010, 01:40 PM
Thanks for your time... It doesn't work this way but i think i will reinstall from scratch and see what happens.
kho91
06-03-2010, 12:05 PM
i changes threads to /sujet it's work, but all of old url on threads/... are don't word i have error
Carnage
06-04-2010, 09:18 AM
The best way around that is to leave the old rewrite rule for threads in place.
Also, don't forget to hit installed :)
sunkapoor22
07-30-2010, 11:17 PM
I am looking to accomplish this, is this possible?
Currently I'm using "Basic Friendly URLs" which show a forum at:
http://www.domain.com/forums/forumdisplay.php?44-televisions
http://www.domain.com/forums/forumdisplay.php?96-cars
I would like the above two forum categories to display as:
http://www.domain.com/forum/televisions
http://www.domain.com/forum/cars
--
And then the threads inside forum categories currently display as:
http://www.domain.com/forums/showthread.php?24-sony-tv
http://www.domain.com/forums/showthread.php?87-honda-accord
I would like the above two forum threads to display as:
http://www.domain.com/forums/televisions/sony-tv
http://www.domain.com/forums/cars/honda-accord
Thank you!
Carnage
08-01-2010, 10:42 AM
1, you need to have the number in the url so www.d.com/forums/1-cars
2, out of the box this mod doesn't do what you want for forum threads, however if you look at the experimental code there are some examples that may do what you want.
suiyuan
09-04-2010, 03:53 AM
Hi,Carnage-
Great MOD, Thank you very much.
Actually, I don't care any long tail of rewrite mod.
I hope change the
www.a.com/threads/2277- title
to
www.a.com/threads/2277/
or even better
www.a.com/threads/2277-p1.html
www.a.com/threads/2277-p2.html
www.a.com/threads/2277-p3.html
......
Same as threads, I don't care long tail of forums.
I hope change the
www.a.com/forums/2-forumname
to
www.a.com/fourms/2/
or even better
www.a.com/fourms/2-p1.html
www.a.com/fourms/2-p2.html
www.a.com/fourms/2-p3.html
........
hope get your help.
Thanks again!
mofeu
11-05-2010, 11:27 PM
I have a greek site and for example I have the following link
http://www.mofeu.eu/forum/showthread.php?5911-Εμείς-πάντως-δεν-φεύγουμε-από-εδώ/page2
and I don't want to appear the text between the link . Can I use this mode?
Thanks in advance
Carnage
11-06-2010, 08:31 AM
I have a greek site and for example I have the following link
http://www.mofeu.eu/forum/showthread.php?5911-Εμείς-πάντως-δεν-φεύγουμε-από-εδώ/page2
and I don't want to appear the text between the link . Can I use this mode?
Thanks in advance
You need to make sure that the default vbulletin seo urls work first. If they will, some of the code in the experimental folder will allow you to build your own url structure without the text in it if you wish, this will require some programming ability.
BarelyHangingOn
11-08-2010, 11:02 PM
Does anybody by chance have a convert from the old Zoints SEO to use with this mod. I am losing all of my pages listed in Google. I don't have the brain power to figure it out.
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([a-z0-9_\-]*-(f|all)[0-9]+(p[0-9]+|/index[0-9]*)?\.html)$ forumdisplay.php/$1 [QSA,L]
RewriteRule ^([a-z0-9_\-]*-(t|p)[0-9]+(p[0-9]+|/index[0-9]*)?\.html)$ showthread.php/$1 [QSA,L]
RewriteCond %{REQUEST_URI} !(index\.php|\.css) [NC]
RewriteRule ^(archive|sitemap)/(.*)$ $1/index.php/$2 [QSA,L]
webmastershome
11-11-2010, 06:53 AM
You can use the below code to redirect to new url
RewriteRule ^([a-zA-Z0-9_-]+)-f([0-9]+)\.html$ forumdisplay.php?f=$2 [QSA,L]
RewriteRule ^([a-zA-Z0-9_-]+)-t([0-9]+)\.html$ showthread.php?t=$2 [QSA,L]
May be this will help you.
TheInsaneManiac
12-11-2010, 03:44 AM
Why do my links look like:
/showthread.php?55-Rules-*Updated-As-Of-July-8th-2008*&p=302#post302
How do I get the whole showthread part out?
4.0.8
pizad_sura
01-12-2011, 09:47 AM
is this mod support 4.1.1 ?
Carnage
01-14-2011, 05:41 AM
Why do my links look like:
/showthread.php?55-Rules-*Updated-As-Of-July-8th-2008*&p=302#post302
How do I get the whole showthread part out?
4.0.8
You need to enable friendly urls (specifically mod rewrite urls) in your vbulletin settings first before this mod will work.
is this mod support 4.1.1 ?
I've not yet had time to test this mod fully with any version above 4.0.5 I think that changes in either 4.1.1 or in 4.1.2 may cause this mod to break; my advice would be to test thoroughly on a dev board prior to deploying it live.
mofeu
01-28-2011, 10:56 PM
You need to make sure that the default vbulletin seo urls work first. If they will, some of the code in the experimental folder will allow you to build your own url structure without the text in it if you wish, this will require some programming ability.
Thanks Carnage and how is tha possible?
Carnage
02-03-2011, 05:50 AM
As I said, the code in the experimental folder should provide sufficient examples that you can build your own complex url schemes.
mofeu
02-03-2011, 04:21 PM
Thank you,I made it
pitt34
02-13-2011, 08:26 AM
Could you make it compatible with 4.1.1?
Drakie
02-13-2011, 10:56 AM
Could you make it compatible with 4.1.1?
That would be great. :)
pitt34
03-13-2011, 05:49 PM
So, we have to wait :(
LichtMann
04-26-2011, 12:00 AM
It is possible to add more files? for example I have example.php?do=view&id=1.
final kaoss
06-30-2011, 05:56 PM
doubt it.
pitt34
07-04-2011, 10:39 AM
Is it still supported?
Carnage
07-09-2011, 07:34 AM
I no longer have time to support this mod, I've marked it as upsupported and have marked the code as reusable. Perhaps someone with more time can turn this into a more functional modification that works with the latest versions.
zero477
03-23-2012, 07:09 PM
Hello Carnage,
Everything works fine until step:
4. Import the product.
After this step is completed nothing works :(
Do I have to completely change the .htacess file to the one created with the link?
Killhunter
09-08-2012, 09:18 AM
Push ;)
fxdigi-cash
03-04-2013, 01:26 AM
hi
I'm wondering if you can shorten a url within vb from
www.domain.com/forum/main.php
to
www.domain.com/main.php
knowing that the forum is located in subforum /forum not in the main domain....
I believe it is possible, but how??
any idea?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.