Fork me on GitHub
Current releases are 2.1.3 (9 Sept 2014) and 2.0.18.13 (5 Aug 2014)

Ready for 2.1? Find out if your plugins are compatible. 2.0 will no longer be updated after Dec 2014.

Friendly Urls

MarkMark Vanilla Staff
edited February 2007 in Vanilla 1.0 Help
This discussion is related to the Friendly Urls addon.
Friendly Urls
«13

Comments

  • 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)
  • I didn't see any .htaccess file that came with Vanilla.

    Not even an invisible one!

    Posted: Tuesday, 27 March 2007 at 4:32PM

  • Huh? Which is the right one to use?
  • MarkMark Vanilla Staff
    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...
  • MarkMark Vanilla Staff
    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
    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. :)
  • Quote: Mark
    pic 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. pic
    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/
  • 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
  • Quote: sujang
    pic The result was same with or without .htaccess. It seems that vanilla can not read .htaccess. pic
    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 = '') {
    $TargetUrl = ForceString($TargetUrl, $this->Context->SelfUrl);
    if ($FormID != '') $FormID = ' id="'.$FormID.'"';
    return '<form'.$FormID.' method="'.$PostBackMethod.'" action="'.GetUrl($this->Context->Configuration, $TargetUrl).'"'.($EncType != '' ? ' enctype="'.$EncType.'"' : '').($TargetFrame != '' ? ' target="'.$TargetFrame.'"' : '').'>'
    .$this->PostBackParams->GetHiddenInputs();
    }


    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]
    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']);
    $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
«13
Sign In or Register to comment.