Not signed in (Sign In)

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

  1.  
    Can please some one take a look at my site and if at all explain why when I turn on Generate Cruft-Free URLs, i seem to get doubles slash before the actual url i.e www.whatever.com//the rest of the url in mod_rewrite.

    looked in the Database for trailing slashed under the Path section, not a thing

    heres the the .htaccess


    # BEGIN Plogger
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_URI} !(\.|/$)
    RewriteRule ^.*$ http://www.planet-templates.com%{REQUEST_URI}/ [R=301,L]
    RewriteCond %{HTTP_HOST} !^www [NC]
    RewriteRule ^(.*)$ http://www.planet-templates.com/$1 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^.*$ - [S=2]
    RewriteRule feed/$ plog-rss.php?path=%{REQUEST_URI} [L]
    RewriteRule ^.*$ index.php?path=%{REQUEST_URI} [L]
    </IfModule>
    # END Plogger


    here the URL

    http://www.planet-templates.com

    Cheers
    Michael
    • CommentAuthorbloggus
    • CommentTimeNov 11th 2009
     
    I have the same problem. Doubles slashes = // , after the host.
    •  
      CommentAuthorsidtheduck
    • CommentTimeNov 11th 2009
     
    Try this. Open plog-load-config.php and look for the following code starting on line 94:
    // if mod_rewrite is on and we're not embedded, remove the file basename
    if ($config['use_mod_rewrite'] == 1 && $config['embedded'] == 0) {
    $config['baseurl'] = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/';
    // otherwise just use our cleaned up version of $_SERVER['PHP_SELF'] from plog-globals.php
    } else {
    $config['baseurl'] = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
    }

    and replace it with this:
    // if mod_rewrite is on and we're not embedded, remove the file basename
    if ($config['use_mod_rewrite'] == 1 && $config['embedded'] == 0) {
    $config['baseurl'] = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
    // Verify URL for a trailing slash. If not, add one.
    if ($config['baseurl']{strlen($config['baseurl'])-1} != '/') {
    $config['baseurl'] = $config['baseurl'].'/';
    }
    // otherwise just use our cleaned up version of $_SERVER['PHP_SELF'] from plog-globals.php
    } else {
    $config['baseurl'] = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
    }
    • CommentAuthorbloggus
    • CommentTimeNov 11th 2009 edited
     
    The code seems to be ok, but a second slash is stil beeing added.
    •  
      CommentAuthorsidtheduck
    • CommentTimeNov 11th 2009
     
    What do you think is wrong with the 5th line? I don't have any errors when I test the code. Can you post an error message?
    • CommentAuthorbloggus
    • CommentTimeNov 11th 2009 edited
     
    Sorrym the error was a copy&paste, but the //slash problem is stil there. Sorry.
    • CommentAuthorbloggus
    • CommentTimeNov 11th 2009
     
    The site is actually working, but the URLS is like, for example
    http://www.domain.com//plogger-test-collection/album-1/492744-original/
    •  
      CommentAuthorsidtheduck
    • CommentTimeNov 11th 2009 edited
     
    Did you copy / paste the entire thing? Line 3 is different in the 2 code examples above.
    • CommentAuthorbloggus
    • CommentTimeNov 11th 2009 edited
     
    Yes.

    I found out that the actual $config['baseurl'] is http://www.domain.com\ - not a slash, but a backslash in the end

    I changed the

    if ($config['baseurl']{strlen($config['baseurl'])-1} != '/')


    to

    if ($config['baseurl']{strlen($config['baseurl'])-1} != '\\')


    and not I got rid of the double slash.

    Do you think it is the best way to do it? Do you know where this backslash is added?
    •  
      CommentAuthorsidtheduck
    • CommentTimeNov 11th 2009
     
    Are you on a windows host by chance? I'm guessing that's where the backslash is added as windows uses backslash for directory separation and linux uses forward slash.

    Did your original URL look like this -> http://www.domain.com\/collection-name/album-name/picture.jpg ?
    • CommentAuthorbloggus
    • CommentTimeNov 11th 2009
     
    Yes, I run Windows server.

    And No, that was the strangest thing. The URL looked like http://www.domain.com//collection-name/album-name/picture.jpg before the changes.
    • CommentAuthorbloggus
    • CommentTimeNov 11th 2009
     
    Ok, I just realized you are using dirname to get the base url ... that will create this problem with the backslash. Thanks for the help, I will have to really looked out for it when upgrade in the future.
    •  
      CommentAuthorsidtheduck
    • CommentTimeNov 11th 2009 edited
     
    weird.

    I'll do some more tests and see if there's an easy universal way to determine this for windows or linux. We're only running into issues here because dirname($_SERVER['PHP_SELF']) returns '/' or '\' instead of just being blank.
    Let me know if you come across anything else in your testing as well.

    p.s. what happens when you echo $_SERVER['PHP_SELF']'? Is there a backslash there?
    • CommentAuthorbloggus
    • CommentTimeNov 11th 2009 edited
     
    $_SERVER['PHP_SELF']

    gives just /index.php

    but

    dirname($_SERVER['PHP_SELF'])

    always gives \ in windows.

    ---

    Maybe just runing
    $config['baseurl'] = str_replace('\\', '/', $config['baseurl']);
    after second line is all it is needed. That will at least solve WIndows issue.
    •  
      CommentAuthorsidtheduck
    • CommentTimeNov 11th 2009 edited
     
    that is odd, but correct per the PHP manual.

    Here is a slightly longer code that should work:
    $config['baseurl'] = 'http://'.$_SERVER['HTTP_HOST'].str_replace('\\', '/', dirname($_SERVER['PHP_SELF']));
    or maybe try this:
    $config['baseurl'] = 'http://'.$_SERVER['HTTP_HOST'].realpath(dirname($_SERVER['PHP_SELF']));
    • CommentAuthorbloggus
    • CommentTimeNov 11th 2009
     
    This works for me.


    // if mod_rewrite is on and we're not embedded, remove the file basename
    if ( $config['use_mod_rewrite'] == 1 && $config['embedded'] == 0) {
    $config['baseurl'] = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
    $config['baseurl'] = str_replace('\\', '/', $config['baseurl']);
    // Verify URL for a trailing slash. If not, add one.
    if ($config['baseurl']{strlen($config['baseurl'])-1} != '/') {
    $config['baseurl'] = $config['baseurl'].'/';
    }
    // otherwise just use our cleaned up version of $_SERVER['PHP_SELF'] from plog-globals.php
    }
    else {
    $config['baseurl'] = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
    }
    •  
      CommentAuthorsidtheduck
    • CommentTimeNov 11th 2009
     
    heh, same thing as I have :D

    Can you check the realpath() example?
    • CommentAuthorbloggus
    • CommentTimeNov 11th 2009
     
    realpath is not the way to go. The str_replace you and me suggestion at the same time is the best solution at this point.

    Thanks! Will make a theme for this one, so maybe I will find more things in time!
    • CommentAuthorbloggus
    • CommentTimeNov 11th 2009
     
    Just FYI

    realpath(dirname($_SERVER['PHP_SELF'])) gives just C:\
    • CommentAuthorashkir
    • CommentTimeJun 8th 2011
     
    Thanks bloggus! That fixed my problem!