This is an add-on that allows you to make your Vanilla installation use search-engine-friendly urls rather than the standard ?Discussion=111 type of querystrings.
It requires Apache and mod_rewrite on your server. Be sure to read the readme.txt file for install instructions.
The July 1st update includes a number of new rules and fixes for problems that various people on various systems ran into.
Other Requirements (if any):
Wanderer Hey Mark, do you realise that the .htaccess file comes in as invisible on OS X?
Maybe it should be called dot_htaccess with a tip in the readme.
Posted: Tuesday, 27 March 2007 at 12:36PM
You really should be using the .htaccess file which comes with Vanilla instead of this one, Wanderer (unless this one gets updated). This one can cause problems in various ways (mostly related breaking other extensions)
Wanderer I didn't see any .htaccess file that came with Vanilla.
Not even an invisible one!
Posted: Tuesday, 27 March 2007 at 4:32PM
just over write the one by Dinoboff.
Huh? Which is the right one to use?
Mark I didn't realize that there was an htaccess with the release. Is there? I don't see it in svn and the release archive comes straight from there...
Mark Nope - just downloaded it to check and there's nothing (as it should be)...
AFAIK this add-on is up to date and fully functional.
Huh. You're right. I'm sure that there was a .htaccess file in one of the releases though, 1.0.3 perhaps. I think the difference was that at some point there was a version which didn't have this: #Extensions<br />RewriteRule ^extension/$ extension.php [QSA,L] Ah. I did a search, see this comment and the ones after it.
But I see the Friendly URLs add-on has been updated, and it all looks just fine now. :)
Wanderer #ccc;background:#fef9e9;padding:0.42em 0.8em;width:80%;">Quote: Mark
Nope - just downloaded it to check and there's nothing (as it should be)...
AFAIK this add-on is up to date and fully functional.
Mark, the .htaccess file in the add-on broke my Dplayer extension.
I replaced it with Dinoboff's version and it worked again.
I don't know enough about .htaccess files to pinpoint the problem.
Posted: Wednesday, 28 March 2007 at 8:09AM
Those of you on Mac OS who can't see hidden files, can follow these instructions to make hidden file viewable in finder
http://www.osxfaq.com/DailyTips/02-2005/02-01.ws
I'm kinda new to vanilla and kinda bad at mod_rewrite but I was wondering would it be possible to make the category URLs use the category name rather than the ID ?
Mark,
I've noticed that the discussion URLs don't redirect to automatically add the trailing slash. So, if I e-mailed this discussion URL to someone, and I forgot the trailing slash, it would fail, like this:
http://lussumo.com/community/discussion/5425/friendly-urls
...whereas that url should automatically redirect to:
http://lussumo.com/community/discussion/5425/friendly-urls/
Isn't there an easy RewriteRule that redirects to automatically the trailing slash for the discussions?
EDIT: Weird, I think this is working correctly in the Add-On, but it doesn't seem to be working on this forum.
Though, I am definitely seeing problems like this one:
http://lussumo.com/community/search
...which needs to redirect to:
http://lussumo.com/community/search/
Wanderer dan39, I noticed this too but it does not happen on my forum.
However, I'm using Dinoboff's version of the .htaccess file, don't know it that's the fix though.
Posted: Friday, 30 March 2007 at 12:18PM
Ok i have a couple of doubts here. I appreciate your reply with some help.
1) I'm encountering a problem with Friendly URLs add. When I click the link:
myforum.com/search/ or myforum.com/cetegories/ the browser said: HTTP 404 not found but I can still go to those pages with the old URLs search.php and categories.php
what is wrong here?
2) the browser still find all the old URLs with .php , it is supposed to happen? Then I have duplicated pages and that is not good. It is something wrong in the .htaccess ??
Pleassssse help
check this stuff (if you haven't already)
1) have mod_rewrite enabled in you httpd.conf file
2) use the .htaccess file mentioned by wanderer above
3) if you are using the page manager extension "resync" your tabs (setting>>page management) and click on the link at the bottom of the form.
I had the same problem and these steps fixed it.
If that doesn't improve things try an apache restart
>> "sudo apachectl graceful" should cover it if you are only change the .htaccess
>> but you might need a full restart if you are changing the httpd.conf file. "sudo apachectl restart"
if you are messing with these files take a copy or them first so you can revert as you might end up with an apache install that won't restart if you mess it up.
HTH
Thank you for your tip, neilroberts.
Unfortunately, the resync trick did not work for me. I had to reconfigure the page manager setting.
Adding one queston, can this extension be apply-able on a site running 2-byte language?
After applying this extension, when I point a discussion titled with 2-byte language, it reveals the link url something like these, ie
"/path/path/-/#item_0" or "/path/path//#item_0". Double / or - between /
The result was same with or without .htaccess. It seems that vanilla can not read .htaccess.
Something should be wrong with my setting.
Circumstances:
localhost on Mac OS 10.4.8
Apache 1.3 with mod_rewrite
PHP 5.2.0
MySQL 5.0.27
Extensions : Attachments 2.1 Category Jumper 1.0 CategoryRoles 0.5 Extended Application Form 1.0 Forced BBCode 0.1.0 Guest Post 1.4.1 Inline Images 1.3 JQThickBox 1.1.3 JQuery 1.1.4 Members Page 1.2.1 Multi File Upload 1.1 Page Manager 2.4.3 Sidepanel 1.0 Signatures 1.0.1 Transmogrifier 1.2 Vanillacons 1.3
Wanderer #ccc;background:#fef9e9;padding:0.42em 0.8em;width:80%;">Quote: sujang
The result was same with or without .htaccess. It seems that vanilla can not read .htaccess.
It's the web server that reads the .htaccess file, not Vanilla, and no extension should have any effect on the .htaccess file either.
Is the .htaccess file in the root folder of your forum?
Posted: Thursday, 5 April 2007 at 8:48AM
Thank you for your reply, Wanderer.
Yes, I tried some test, putting .htaccess onto /WebServer/Documents/Vanilla/, /WebServer/Documents/, and even onto /WebServer/, and each time I restarted the Server. But the results are all the same.
Hello, I'm having problems with this rewrite with subdomains, when my forum URL is something like forums.myweb.com and I click in something, nothing happens, it loads again the forum index.
I also tried adding the http://forum.website.cl/ in every single rule, but it still doesn't works.
Thanks in advantage,
JAC
Hi neilroberts,
I'm using Dinoboof htaccess and I'm not using the page manager extension. The browser (and search engines) are still finding all the old URLs with .php , it is supposed to happen? Then I have duplicated pages and that is not good. It is something wrong in the .htaccess ?? I have been told the htaccess needs a major clean effort because it is not very good.
Hi Stuart,
From what I understand (and from messing around with my install) the orginal URLs will still work.
What mod_rewite does is when it gets a request to
http://forum.mydomain.com/categories/
it tells the server to execute to code located at
http://forum.mydomain.com/categories.php
and keeps the URL in the browser the same (rather than a straight redirect where to URL in the browser changes).
Over a period of time as you forum is re-crawled you will see the old style URLs disappear from your listings (this is what I understand will happen at least).
HTH
Neil
There's a problem I experienced using the "Poll"-Extension by Jazzman but that could possibly affect other extensions as well when Friendy Urls is activated:
The Poll-Extension, when a poll is added to a discussion, inserts a <form%gt; to... vote.
Yeah, but that's not working with Friendly Urls enabled, because the form is started via$this->Get_PostBackForm('frmVote')
This very method in Framework.Class.Control.php reads:function Get_PostBackForm($FormID = '', $PostBackMethod = 'post', $TargetUrl = '', $EncType = '', $TargetFrame = '') {<br /> $TargetUrl = ForceString($TargetUrl, $this->Context->SelfUrl);<br /> if ($FormID != '') $FormID = ' id="'.$FormID.'"';<br /> return '<form'.$FormID.' method="'.$PostBackMethod.'" action="'.GetUrl($this->Context->Configuration, $TargetUrl).'"'.($EncType != '' ? ' enctype="'.$EncType.'"' : '').($TargetFrame != '' ? ' target="'.$TargetFrame.'"' : '').'>'<br /> .$this->PostBackParams->GetHiddenInputs();<br />}
As you can see, the $TargetUrl parameter is left to default which means the following line in Get_PostBackForm is executed:$TargetUrl = ForceString($TargetUrl, $this->Context->SelfUrl);
In a discussion, this normally sets the target variable to comments.php which is, because Friendly Urls
is activated, /discussion/ (slashes added to show it's a directory
, that's not contained in the exact value if I remember correctly). So the form will read:<form id="frmVote" action="http://vanilla.art-fx.org/discussion/" method="post">
Well, /discussion/
isn't accepted: this delivers a 404 error. What's missing? The discussion's ID and the url-slug of the discussion's title: /discussion/31/some-title
.
I don't know whether this extension is the right place to mention that point, but as you, Mark, are programming Vanilla and this extension both yourself I hope that's no problem :)
Please fix this issue as soon as possible, making your Get_PostBackForm method work as it's intended so one can enable Friendly Urls
and Poll
.
Oh, there was yet another thing: extensions that might need the DiscussionID parameter weren't redirected at all, so I added the following rule to your .htaccess file:RewriteRule ^extension/([0-9]+)/?(.*)$ extension.php?DiscussionID=$1&$2 [QSA,L]
The Poll extension (yeah, again :)) needs this to make Add Poll to Discussion
working. I think the way it's redirected ($2 for optional parameters) is generic enough, but probably rules like the following are needed as well:RewriteRule ^extension/([0-9]+)/$ extension.php?DiscussionID=$1 [QSA,L]<br />RewriteRule ^extension/([0-9]+)$ extension.php?DiscussionID=$1 [QSA,L]
DivineDominion,
Dinoboff's .htaccess is a good workaround for all of the Poll issues you're talking about.
http://lussumo.com/community/discussion/2803/
The Poll extension really needs to be tweaked a bit. For instance, you can fix the $TargetUrl issue on comment.php pages by making the following edits to the Poll add on:
Change Line 6 of /extensions/Poll/templates/poll_vote.php to be this:'.$this->Get_PostBackForm('frmVote', 'post', 'voteform.php').'
...And then add the following below Line 6 of /extensions/Poll/conf/settings.php:$Context->Configuration['REWRITE_voteform.php'] = 'comments.php';
...but doing that screws up the Poll in the Panel of the index.php pages. So, to get Polls to work on index pages you have make the Poll on index pages call an unedited/original version of templates/poll_vote.php. So essentially you create two templates, one for the index.php pages and one for the comments.php and have the Panel vote form call the original version.
But, the easiest thing to do is to just use Dinoboff's .htaccess for a quick fix.
Hello neilroberts,
It is not good that the orginal URLs will still work. It needs a complete redirect so when someone type the old URL it gets redirected to the new one. Search engines crawld the old one and they need to be redirected to the new ones otherwise you get the duplicate. How can we do a complete 301 redirect with the Dinoboof htaccess ??
Does anyone else have this AddOn installed with the 'Who's Online' extension?
I am experiencing a problem with viewing a user's account while already in a discussion. When I am viewing a Discussion and then click on someone's username under the 'Who's Online' box, it should take me to their user account but it doesn't. I am just sent right back to the conversation I'm viewing, but with a different URL at the top now.
For example, I am viewing the page:
http://www.fngeeks.net/vanilla/discussion/18/welcome/#Item_17
I then click on my username 'Gabe' under 'Who's Online' which has the HREF set to:
http://www.fngeeks.net/vanilla/discussion/18/welcome/account.php?u=2
and end up viewing the same Discussion instead of being taken to my user account info.
I have a feeling this is a problem with the .htaccess file and the RewriteRule (or lack thereof). Unfortunately I am not very good with mod_rewrite and don't understand the file that well.
The contents of my .htaccess file are as follows:
RewriteEngine On
Options +FollowSymLinks -Multiviews
#Discussions
RewriteRule ^discussions$ index.php [QSA,L]
RewriteRule ^discussions/$ index.php [QSA,L]
RewriteRule ^discussions/([0-9]+)$ index.php?page=$1 [QSA,L]
RewriteRule ^discussions/([0-9]+)/$ index.php?page=$1 [QSA,L]
RewriteRule ^([0-9]+)$ index.php?CategoryID=$1 [QSA,L]
RewriteRule ^([0-9]+)/$ index.php?CategoryID=$1 [QSA,L]
RewriteRule ^([0-9]+)/([0-9]+)$ index.php?CategoryID=$1&page=$2 [QSA,L]
RewriteRule ^([0-9]+)/([0-9]+)/$ index.php?CategoryID=$1&page=$2 [QSA,L]
#Comments
RewriteRule ^discussion/([0-9]+)/([0-9]+)/(.*)$ comments.php?DiscussionID=$1&page=$2 [QSA,L]
RewriteRule ^discussion/([0-9]+)/([0-9]+)/(.*)/$ comments.php?DiscussionID=$1&page=$2 [QSA,L]
RewriteRule ^discussion/([0-9]+)/(.*)$ comments.php?DiscussionID=$1 [QSA,L]
RewriteRule ^discussion/([0-9]+)/(.*)/$ comments.php?DiscussionID=$1 [QSA,L]
RewriteRule ^discussion/([0-9]+)/([0-9]+)$ comments.php?DiscussionID=$1&page=$2 [QSA,L]
RewriteRule ^discussion/([0-9]+)/([0-9]+)/$ comments.php?DiscussionID=$1&page=$2 [QSA,L]
RewriteRule ^discussion/([0-9]+)$ comments.php?DiscussionID=$1 [QSA,L]
RewriteRule ^discussion/([0-9]+)/$ comments.php?DiscussionID=$1 [QSA,L]
#Categories
RewriteRule ^categories/$ categories.php [QSA,L]
#Account
RewriteRule ^account/$ account.php [QSA,L]
RewriteRule ^account/([0-9]+)$ account.php?u=$1 [QSA,L]
RewriteRule ^account/([0-9]+)/$ account.php?u=$1 [QSA,L]
#Search
RewriteRule ^search/$ search.php [QSA,L]
RewriteRule ^search/([0-9]+)$ search.php?page=$1 [QSA,L]
RewriteRule ^search/([0-9]+)/$ search.php?page=$1 [QSA,L]
RewriteRule ^search/saved/([0-9]+)$ search.php?SearchID=$1 [QSA,L]
RewriteRule ^search/saved/([0-9]+)/$ search.php?SearchID=$1 [QSA,L]
RewriteRule ^search/saved/([0-9]+)/([0-9]+)$ search.php?SearchID=$1&page=$2 [QSA,L]
RewriteRule ^search/saved/([0-9]+)/([0-9]+)/$ search.php?SearchID=$1&page=$2 [QSA,L]
#Post
RewriteRule ^post/$ post.php [QSA,L]
RewriteRule ^post/([0-9]+)$ post.php?CommentID=$1 [QSA,L]
RewriteRule ^post/([0-9]+)/$ post.php?CommentID=$1 [QSA,L]
RewriteRule ^post/category/([0-9]+)$ post.php?CategoryID=$1 [QSA,L]
RewriteRule ^post/category/([0-9]+)/$ post.php?CategoryID=$1 [QSA,L]
#Settings
RewriteRule ^settings/$ settings.php [QSA,L]
#People
RewriteRule ^people/$ people.php [QSA,L]
#extension
RewriteRule ^extension/$ extension.php [QSA,L]
# Prevent some little bad effects of Friendly Urls on relative links in some
# extensions
RewriteRule ^(discussions|categories|search|post|settings|people|[0-9]+)/(extensions|themes|images|ajax)/(.*) $2/$3 [QSA,L]
RewriteRule ^(discussions|categories|search|post|settings|people|[0-9]+)/(account.php|categories.php|comments.php|extension.php|index.php|people.php|post.php|search.php|settings.php) $2 [QSA,L]
RewriteRule ^discussion/([0-9]+/){1,2}[^/]*/(extensions|themes|images|ajax)/(.*) $2/$3 [QSA,L]
RewriteRule ^discussion/([0-9]+/){1,2}[^/]*/(account.php|categories.php|comments.php|extension.php|index.php|people.php|post.php|search.php|settings.php) $2 [QSA,L]
RewriteRule ^(discussions|account|search|post|[0-9]+)/.+/(extensions|themes|images|ajax)/(.*) $2/$3 [QSA,L]
RewriteRule ^(discussions|account|search|post|[0-9]+)/.+/(account.php|categories.php|comments.php|extension.php|index.php|people.php|post.php|search.php|settings.php) $2 [QSA,L]
#Pages
RewriteRule ^page/(.*)$ index.php?Page=$1 [QSA,L]
Nevermind. I was able to fix the problem by rewriting a line in the Who's Online extension.
Anyone got this working? lol
Just tried it out now, changing round some stuff in the htaccess such as /categories/ to /cat/ and so on... but the actual URL retains /categories/ ... any reason? :S
Nevermind. I was able to fix the problem by rewriting a line in the Who's Online extension.
Care to tell us what you changed gpreston? It could help out Chris here...
I would guess its the same relative URL problem we saw yesterday...
Line 163: $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), "account.php?u=" . $name["UserID"],NULL,"title=\"$TimePast\"");
Should be: $Url = GetUrl($Context->Configuration, 'account.php', '', 'u=', $name['UserID']);<br /> $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), $Url, NULL, 'title="$TimePast"');
Edit: More 'proper' use of GetUrl, thanks to finding Gprestion's fix: Who's Online # 42
How about:#Extensions<br />RewriteRule ^extension/(.+)/(.+)/$ extension.php?PostBackAction=$1&page=$2 [QSA,L]<br />RewriteRule ^extension/(.+)/(.+)$ extension.php?PostBackAction=$1&page=$2 [QSA,L]<br />RewriteRule ^extension/(.+)/$ extension.php?PostBackAction=$1 [QSA,L]<br />RewriteRule ^extension/(.+)$ extension.php?PostBackAction=$1 [QSA,L]
Reason is me writing my extension and urls looking like: domain.tld/extension/LightGallery/Berlin/
Howevery this probably will mess up some other extensions, but as I see it nearly none of them support friendly-urls anyway ;-)
Going on from this - wouldn't it be nice to have the same kind of thing for settings? That way, to change the settings for the Packer extension we would just type in /settings/Packer. The following seems to work well, but if someone who knew what they were doing could check it for fatal errors that would be great :) Of curse, then we need to get Vanilla to write the links like this (how?).#Settings<br />RewriteRule ^settings/$ settings.php [QSA,L]<br />RewriteRule ^settings/(.+)/$ settings.php?PostBackAction=$1 [QSA,L]<br />RewriteRule ^settings/(.+)$ settings.php?PostBackAction=$1 [QSA,L]
Resilient Would it be possible to use this extension in such a way where rather than gettinghttp://vanilladirectory.com/account/1/
you would be able to pull the registered username and have it displayhttp://vanilladirectory.com/account/resilient/
This "extension" should be build in into vanilla, then nice short urls would be possible.
Doing it by .htaccess is completly wrong :(
but what you are asking is nevertheless possible. it would require changing the account page - another extension, or adding to this
It is built into Vanilla. Check GetUrl() in library/Framework.Function.php.
Yeah, but I meant the other part. Parsing Short-Urls.
I'm not sure myself how to do it so it will work on alle servers.
I always use ORIG_PATH_INFO$arguments = explode('/', $HTTP_SERVER_VARS['ORIG_PATH_INFO']);
However, this has nothing to do with the question above ;)
Resilient:
I did that a bit back--you have to edit the theme file to build the user name on the URL instead of the ID, (theme files comments.php, account.php discussions.php and I think one for a search page) and then there is a GetUserIDByName() function somewhere...
Will have a look.
When you're on a Page Manager page, because those pages have /page/ artificially inserted into the URLs, it then causes other links on those pages to have /page/ inserted into them as well. Eg /people.php to sign in/out becomes /page/people.php (resulting in an error) etc..
How can I make the Page Manager pages not have the /page/ in front of them, so pages are like www.mydomain.com/pagename/ same as the rest of the friendly URLs?
Also how do I get the Contact Form extension to have a friendly URL?
Thanks in advance..
Resilient WallPhone
Many thanks, I appreciate your help and look forward to getting an update from you when you figure it out. :)
Is this supposed to make everything load slower ? Or did I do something wrong.
This doesn't seem to use a 301 redirect for every re-written url,, so I'm scared to use this, for it should cause serious duplicate content issues, cause you'll have two sets of urls that can access the same page. Plus if you put most recent discussions or something out side vanilla on a page, it'll only have the dynamic url displayed, in turn when a search engine goes through this link, it'll pick up duplicate content. Anyone know of a solution?
WallPhone, any news on Resilient's /account/username request?
I'm working on migrating that hack into a 'real' extension, but I'm in the middle of other projects that have higher priority at the moment.
It's a little more complicated as an extension because usernames can have characters that aren't allowed in URLs, so that would have to be limited and checked for in existing accounts when enabled.
ProfileDiscussions just happened to be something I could bang out during a lunch break, so it skipped the line :-)
I've tried multiple times to get the friendly URL's to work, but I keep getting the same problem. Vanilla will not allow me to keep a conf/setting.php file as it goes directly into update/install mode at which point it asks me to remove the conf/setting.php file before it can proceed. Any idea as to why Vanilla thinks I am trying to reinstall? I've even changed the settings file to include all of my own installations info - no difference.
@waynem80: 301 redirects by definition only apply to "redirects." These are RewriteRules. Nothing is being redirected here.
A redirect means that the browser is instructed to physically changes from URL A -> URL B. But a RewriteRule just means that URL A = URL B. Redirects and RewriteRules are two different things. There's no way to create a "301 RewriteRule." It wouldn't make any sense.
You would only have to worry about duplicate content if there are links out there in the search engines to your un-friendly URLs.
Friendly Urls still needs some work.
It just isn't as friendly as it should be, IMO.
The Url structure should be more like a file structure.vanilla dir<br /> |<br /> category<br /> |<br /> discussion<br />
so categories would be:/vanilla/category-name/
discussions would be:/vanilla/category-name/discussion-name/
and if you can't do it that way you should at least get rid of all the numbers so discussions would be:vanilla/discussion/discussion-name/
instead of:vanilla/discussion/stupid-number/discussion-name/#item_another-stupid-number
The #item_ thing isnt as big of a deal because i'm guessing its for going to the last comment. but couldnt it say #pgbottom or something instead?
The reason you have 'stupid numbers' in the URL is because it's impossible to identify a discussion purely by it's title.
That should be fixed then. Cuz that aint friendly to me. :)
Using the 'stupid numbers' is actually rather handy when the original poster of a discussion decides to change the title of the discussion one day. Even if the title changes, everyone's bookmarks will still work.
Also, you'll notice that Netflix does the exact same thing as Vanilla
http://www.netflix.com/Movie/Vanilla_Is_Awesome!!!!!!/70023451
It's the number "70023451" that makes the URL valid, not the name. The only reason why Netflix (and Friendly URLs) adds the text into the URL is to add some extra keywords into search engines. It's those added keywords that makes it "friendly."
It's not like Vanilla invented this kind of naming convention. It's pretty widespread.
well it still looks ugly but i guess that makes sense. what about showing the category name in urls?
Edit: I dunno.. I guess I'm just used to wordpress. You just tell it what url structure you want and it spits out a .htaccess file for you and you dont need any ID's if you dont want them. Oh well, I love vanilla anyway :)
Addons are custom features that you can add to your Vanilla forum. Addons are created by our community of developers and people like you!
We review addons to make sure they are safe and don't cause bugs. An addon is considered to be "Vanilla Approved" once our review process is complete.