Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1
    Casual Pligger liotier's Avatar
    Joined
    Jul 2007
    Posts
    70

    [SOLVED] URL method 2 mostly working but hostname missing in some links

    #b^2 links / Published News is a Beta 9.7 Pligg now set up with URLMethod = 2. Most of the links are fine as I am able to navigate to their targets. But the link that appear under the title and under the voting button is wrong : the hostname is missing. Let's take one example one of the entries for example : the href comes out as "//5_regular_expressions_every_web_programmer_should_ know/" (Firefox spontaneously adds http: but the HTML source contains only what I mentioned.

    I am guessing that one or more rewrite rule is wrong and I can't find which one... As Brian Moore once put it : "Despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still voodoo''...

    I have tried to trace the origin of the data, but I don't quite understand Smarty so the relationship between print_summary() in libs/link.php and link_summary.tpl has me all confused.

    So here is my .htaccess... Hopefully one of you can tell me if something obvious is wrong...

    Code:
    ##### Gzip Begin #####
    ## To enable Gzip and decrease the load times of your Pligg site
    ## change /home/path/to to your absolute server path and remove the two # from both lines
    php_value auto_prepend_file /home/jim/www/infotain.ruwenzori.net/begin_gzip.php
    php_value auto_append_file /home/jim/www/infotain.ruwenzori.net/end_gzip.php
    
    AddType "text/javascript" .gz
    AddEncoding gzip .gz
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{THE_REQUEST} ^(.*).js
    RewriteCond %{SCRIPT_FILENAME}.gz -f
    RewriteRule ^(.*)\.js $1.js.gz [L]
    ##### Gzip End #####
    
    ##### 404 Error Begin #####
    ## If Pligg is installed in a subfolder, change the below line to ErrorDocument 404 /name-of-subfolder/404error.php
    ErrorDocument 404 /404error.php
    ##### 404 Error End #####
    
    ##### Re-directing Begin #####
    Options +Indexes +FollowSymlinks
    RewriteEngine on
    ## If Pligg is installed in a subfolder, change the below line to RewriteBase /name-of-subfolder
    RewriteBase /
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
    
    ## Remove these two lines if you have a sub-domain like  http://ashdigg.pligg.com  or http://localhost
    ## Keep if your site it like   http://www.pligg.com
    #RewriteCond %{HTTP_HOST} !^www\.
    #RewriteRule ^\/?(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    ##### Re-directing End #####
    
    ##### You can find the below lines pre-made for you in the category management section of the admin panel ######
    #RewriteRule ^(all|pligg)/([^/]+)/?$ story.php?title=$2 [L]
    #RewriteRule ^(all|pligg)/?$ ?category=$1 [L]
    RewriteRule ^(all|Actualit%C3%A9g%C3%A9n%C3%A9rale|Politique|Logiciel|Mat%C3%A9riel|D%C3%A9veloppement|Administration|Arm%C3%A9es|Aviation|Dr%C3%B4le|Bizarre|T%C3%A9l%C3%A9coms|Sports)/([^/]+)/?$ story.php?title=$2 [L]
    RewriteRule ^(all|Actualit%C3%A9g%C3%A9n%C3%A9rale|Politique|Logiciel|Mat%C3%A9riel|D%C3%A9veloppement|Administration|Arm%C3%A9es|Aviation|Dr%C3%B4le|Bizarre|T%C3%A9l%C3%A9coms|Sports)/?$ ?category=$1 [L]
    #####
    
    ##### URL Method 2 ("Clean" URLs) Begin #####
    RewriteRule ^story/([0-9]+)/?$ story.php?id=$1 [L]
    RewriteRule ^story/title/([^/]+)/?$ story.php?title=$1 [L]
    RewriteRule ^story/([0-9]+)/editcomment/([0-9]+)/?$ edit.php?id=$1&commentid=$2
    RewriteRule ^story/([0-9]+)/edit/?$ editlink.php?id=$1
    RewriteRule ^story/([0-9]+)/modify/([a-z]+)/?$ linkadmin.php?id=$1&action=$2
    RewriteRule ^recommend/([a-zA-Z0-9-]+)/?$ recommend.php?id=$1 [L]
    RewriteRule ^category/([^/]+)/?$ index.php?category=$1 [L]
    RewriteRule ^upcoming/category/([^/]+)/?$ upcoming.php?category=$1 [L]
    RewriteRule ^upcoming/([a-zA-Z0-9]+)/?$ upcoming.php?part=upcoming&order=$1
    RewriteRule ^inbox/?$ user.php?view=inbox
    RewriteRule ^user/?$ user.php
    RewriteRule ^user/view/([a-zA-Z0-9-]+)/?$ user.php?view=$1
    RewriteRule ^user/view/([a-zA-Z0-9+]+)/([a-zA-Z0-9+]+)/?$ user.php?view=$1&login=$2
    RewriteRule ^user/view/([a-zA-Z0-9+]+)/login/([a-zA-Z0-9+]+)/?$ user.php?view=$1&login=$2
    RewriteRule ^user/([a-zA-Z-]+)/link/([0-9+]+)/?$ user_add_remove_links.php?action=$1&link=$2
    RewriteRule ^published/?$ index.php
    RewriteRule ^published/([a-zA-Z0-9-]+)/?$ index.php?part=$1
    RewriteRule ^published/([a-zA-Z0-9-]+)/category/([a-zA-Z0-9-]+)/?$ index.php?part=$1&category=$2
    RewriteRule ^upcoming/([a-zA-Z0-9-]+)/category/([a-zA-Z0-9-]+)/?$ upcoming.php?part=upcoming&order=$1&category=$2
    RewriteRule ^search/(.+)/?$ search.php?search=$1
    RewriteRule ^searchurl/(.+)/?$ search.php?url=$1
    RewriteRule ^login/?$ login.php
    RewriteRule ^login/([a-zA-Z0-9-]+)/?$ login.php?return=$1
    RewriteRule ^login/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ login.php?return=$1/$2
    RewriteRule ^register/?$ register.php
    RewriteRule ^topusers/?$ topusers.php
    RewriteRule ^about/([a-zA-Z0-9-]+)/?$ faq-$1.php
    RewriteRule ^upcoming/?$ upcoming.php
    RewriteRule ^submit/?$ submit.php
    RewriteRule ^rss/?$ rss.php
    RewriteRule ^rss/([a-zA-Z0-9-]+)/?$ rss.php?status=$1
    RewriteRule ^rss/category/([a-zA-Z0-9-]+)/?$ rss.php?category=$1
    RewriteRule ^rss/search/([a-zA-Z0-9-]+)/?$ rss.php?search=$1
    RewriteRule ^rss/user/([a-zA-Z0-9-]+)/?$ rss.php?user=$1
    RewriteRule ^rss/user/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ userrss.php?user=$1&status=$2
    RewriteRule ^trackback/([0-9]+)/?$ trackback.php?id=$1
    RewriteRule ^profile/?$ profile.php
    RewriteRule ^admin/?$ admin_index.php
    RewriteRule ^tagcloud/?$ cloud.php
    RewriteRule ^tagcloud/range/([0-9]+)/?$ cloud.php?range=$1 [L]
    RewriteRule ^tag/(.+)/?$ search.php?search=$1&tag=true [QSA,NC,L]
    RewriteRule ^live/?$ live.php
    RewriteRule ^out/([^/]+)/?$ out.php?title=$1 [L]
    RewriteRule ^settemplate/?$ settemplate.php
    RewriteRule ^comments/?$ live_comments.php
    RewriteRule ^live_published/?$ live_published.php
    RewriteRule ^unpublished/?$ live_unpublished.php
    RewriteRule ^logout/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ login.php?op=logout&return=$1/$2
    RewriteRule ^published/page/([^/]+)/?$ index.php?page=$1 [L]
    RewriteRule ^published/page/([^/]+)/category/([^/]+)/?$ index.php?page=$1&category=$2 [L]
    RewriteRule ^published/page/([^/]+)/([^/]+)category/([^/]+)/?$ index.php?page=$1&part=$2&category=$3 [L]
    RewriteRule ^upcoming/page/([0-9]+)/?$ upcoming.php?page=$1 [L]
    RewriteRule ^upcoming/page/([^/]+)/category/([^/]+)/?$ upcoming.php?page=$1&category=$2 [L]
    RewriteRule ^upcoming/page/([^/]+)/upcoming/([^/]+)/?$ upcoming.php?page=$1&part=upcoming&order=$2 [L]
    RewriteRule ^upcoming/page/([^/]+)/upcoming=([^/]+)category/([^/]+)/?$ upcoming.php?page=$1&part=upcoming&order=$2&category=$3 [L]
    RewriteRule ^topusers/page/([^/]+)/?$ topusers.php?page=$1 [L]
    RewriteRule ^topusers/page/([^/]+)/sortby/([^/]+)?$ topusers.php?page=$1&sortby=$2 [L]
    RewriteRule ^admin_links/page/([^/]+)/?$ admin_links.php?page=$1
    RewriteRule ^admin_comments/page/([^/]+)/?$ admin_comments.php?page=$1
    RewriteRule ^admin_users/page/([^/]+)/?$ admin_users.php?page=$1
    RewriteRule ^comments/page/([^/]+)/?$ live_comments.php?page=$1 [L]
    RewriteRule ^published/page/([^/]+)/?$ live_published.php?page=$1 [L]
    RewriteRule ^unpublished/page/([^/]+)/?$ live_unpublished.php?page=$1 [L]
    RewriteRule ^published/page/([^/]+)/([^/]+)/?$ index.php?page=$1&part=$2 [L]
    RewriteRule ^published/page/([^/]+)/range/([^/]+)/?$ ?page=$1&range=$2 [L]
    RewriteRule ^search/page/([^/]+)/search/([^/]+)/?$ search.php?page=$1&search=$2 [QSA,NC,L]
    RewriteRule ^user/page/([^/]+)/([^/]+)/([^/]+)/?$ user.php?page=$1&view=$2&login=$3 [L]
    RewriteRule ^statistics/page/([^/]+)/?$ module.php?module=pagestatistics&page=$1
    RewriteRule ^view/([^/]+)/?$ admin_users.php?mode=view&user=$1
    ##### URL Method 2 ("Clean" URLs) End #####

  2. #2
    Pligg Developer chuckroast's Avatar
    Joined
    Jun 2006
    Posts
    5,478
    ## If Pligg is installed in a subfolder, change the below line to ErrorDocument 404 /name-of-subfolder/404error.php
    ErrorDocument 404 /404error.php

    ## If Pligg is installed in a subfolder, change the below line to RewriteBase /name-of-subfolder
    RewriteBase /

  3. #3
    Casual Pligger liotier's Avatar
    Joined
    Jul 2007
    Posts
    70
    Quote Originally Posted by chuckroast View Post
    ## If Pligg is installed in a subfolder, change the below line to ErrorDocument 404 /name-of-subfolder/404error.php
    ErrorDocument 404 /404error.php
    Pligg is setup in the vhost's root, so the 404 is correct - http://infotain.ruwenzori.net/uiozehoizefh.php produces the expected Pligg 404.

    Quote Originally Posted by chuckroast View Post
    ## If Pligg is installed in a subfolder, change the below line to RewriteBase /name-of-subfolder
    RewriteBase /
    Same here, Pligg being setup in the vhost's root this line is fine, and the fact that most links are working attests that.

    It looks like the rule for the title link (the one that links to the full description and discussion page for the entry) is not inserting the hostname part into the beginning of the URL. So if I understand well, either the rule lacks that variable or the variable is empty.

  4. #4
    Casual Pligger liotier's Avatar
    Joined
    Jul 2007
    Posts
    70
    So... Can anyone give me hints about what to look for to find the faulty rewrite rule ?

  5. #5
    Casual Pligger liotier's Avatar
    Joined
    Jul 2007
    Posts
    70
    Ooops... Looks like I went following the wrong trail. If the link on the page is wrong, the problem is in the way the link is generated !

    I was traumatized by mod_rewrite in my childhood so I was a bit quick to blame it...

    So - time to try to understand Smarty a bit...

  6. #6
    Casual Pligger liotier's Avatar
    Joined
    Jul 2007
    Posts
    70
    Zeroing in on the problem...

    The faulty href is generated by templates/yget/link_summary.tpl at line 67 : <a href="{$story_url}">{$title_short}</a>

    So I confirm that my problem has absolutely nothing to do whatsoever with mod_rewrite. It is actually $story_url that is wrong for some reason.

    That said it does has something to do with URLmethod 2 because the problem only exists in that case.

  7. #7
    Casual Pligger liotier's Avatar
    Joined
    Jul 2007
    Posts
    70
    story_url comes from libs/link.php lines 357-361 :

    PHP Code:
          if ($this->title_url == ""){
             
    $smarty->assign('story_url'getmyurl("story"$this->id)); // internal link to the comments page
          
    } else {
             
    $smarty->assign('story_url'getmyurl("storyURL"$this->category_safe_name(), urlencode($this->title_url), $this->id)); // internal link to the comments page
          

    So I'm now looking to getmyurl() which I found in libs/html1.php

  8. #8
    Casual Pligger liotier's Avatar
    Joined
    Jul 2007
    Posts
    70
    In the definition of getmyurl() in libs/html1.php there is a distinction between ($URLMethod == 1) and ($URLMethod == 2).

    At the beginning of the function I find that the function is supposed to "return getmyurl("storytitle", $var2);" where var2 = title_url. A temporary revert to URLmethod 1 confirms that.

    With that, the relevant part of the function is in the case of ($URLMethod == 2) is :

    If ($x == "storytitle") {return my_pligg_base."/story/title/" . $var1;}

    So my problem is that my_pligg_base."/story/title/" is simply not returned. Only $var1 which a comments above confirms as being category_safe_name.

    So why is my_pligg_base."/story/title/" is not returned ? I have no idea, especially since my_pligg_base is used all over the place with no problem... I'm stalled - a hint would be welcome...

  9. #9
    Casual Pligger liotier's Avatar
    Joined
    Jul 2007
    Posts
    70
    Since cases such as the "out" link which is built by returning among other things my_pligg_base."/out/" works fine, I guess that the bug may not be in libs/html1.php but maybe in the way getmyurl() is called or the way the Smarty assignment is done... For now, this is quite mysterious to me.

    Ok I'll stop thinking aloud - I'll post if I have something new...

  10. #10
    Casual Pligger liotier's Avatar
    Joined
    Jul 2007
    Posts
    70
    Modifying "If ($x == "storytitle") {return my_pligg_base."/story/title/" . $var1;}" in libs/html1.php has no effect, so the problem appears to be in the way this information is used.

Page 1 of 3 123 LastLast

Similar Threads

  1. URL Method 2 - missing category name in stories' links
    By inkluz in forum Questions & Comments
    Replies: 0
    Last Post: 12-16-2009, 01:50 AM
  2. Replies: 0
    Last Post: 09-10-2008, 10:13 AM
  3. [SOLVED] Links not working properly
    By web20guy in forum Questions & Comments
    Replies: 2
    Last Post: 12-16-2007, 11:32 AM
  4. Missing trailing slashes in some links
    By lwc in forum Questions & Comments
    Replies: 1
    Last Post: 11-26-2007, 07:15 AM
  5. [SOLVED] Send Announcement Issue - Missing Definition?
    By P1mpPanther in forum Questions & Comments
    Replies: 3
    Last Post: 10-17-2007, 10:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Pligg Modules and Pligg Templates from Pligg Pro Donate to Pligg CMS Dreamhost Web Hosting Host Gator Web Hosting