The MU forums have moved to WordPress.org

Image rewrite problems (8 posts)

  1. emdee90
    Member
    Posted 16 years ago #

    i have a problem where if I upload an image in a post, it does not display correctly.

    The image is actually at:

    http://domain.com/wp-inst/wp-content/blogs.dir/1/files/2006/05/image.gif

    But the image on the page keeps pointing to

    http://domain.com/files/2006/05/image.gif

    Ideas?

  2. emdee90
    Member
    Posted 16 years ago #

    Nevermind, I solved it with adjusting the .htaccess in the wp-inst directory with this:

    RewriteRule ^([_0-9a-zA-Z-]*)/?files/(.*) /wp-inst/wp-content/blogs.php?file=$2 [L]

    There's a similar line in the current .htaccess if you look closely enough, just adjust the line with the above content.

  3. debrouille
    Member
    Posted 16 years ago #

    i'm using a non-vhost version, and a RewriteRule doesn't help.

    For a non vhost installation one need to change the path
    to access an uploaded image from
    http://www.domain.com/path/blogname/files/year/month/filename
    to
    http://www.domain.com/path/wp-inst/wp-content/blogs.dir/blogid/files/year/month/filename

    I edited the wp-inst/wp-includes/functions-post.php, about line 936 and changed


    $url = trailingslashit($siteurl) . UPLOADS;

    to

    // generate url depending on vhost or not-vhost installtion
    if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' )
    $url = trailingslashit($siteurl) . UPLOADS;
    else {
    global $wpdb, $blog_id;
    $domain = $wpdb->get_var("SELECT domain FROM $wpdb->blogs WHERE blog_id = 1"); // get the domain of the main blog / TODO: do this nicer
    $path = $wpdb->get_var("SELECT path FROM $wpdb->blogs WHERE blog_id = 1"); // get the path of the main blog / TODO: do this nicer
    $url = 'http://' . $domain . $path . 'wp-inst/wp-content/blogs.dir/' . $blog_id . '/' . UPLOADS;
    }

    There might be a bettter way!
    Especially i'm not sure if one can rely in the fact that the blog with blog_id==1 actually IS the main blog.

    Has anyone an idea on how to make this better?
    Can i rely on that blog_id==1 trick?

  4. debrouille
    Member
    Posted 16 years ago #

    has anybody running a non-vhost installation get emdee90's solution (see above) work?
    emdee90, are you running a vhost install?

  5. drmike
    Member
    Posted 16 years ago #

    I was running a non-vhost install. There's too much of the code (like most of the admin menus) that's designed just for the vhost version. I've got to admit that I finally gave up on it.

  6. debrouille
    Member
    Posted 16 years ago #

    you lucky guy! i need the non-vhost install. I'm fixing step by step what i need ;-(

    I try to keep record of all those changes, so i might be able to list all fixes to get the non-vhost install working better..

  7. drmike
    Member
    Posted 16 years ago #

    Make sure you keep a record of them as you'l need to do them all again after an upgrade.

    Maybe Donncha will grab your notes. *HINT!* :)

  8. doga
    Member
    Posted 16 years ago #

    Hello emdee90,

    this is my .htaccess code

    RewriteEngine On
    <Files wp-content/blogs>
    ForceType application/x-httpd-php
    </Files>
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    </IfModule>

    Where should i put your code?
    RewriteRule ^([_0-9a-zA-Z-]*)/?files/(.*) /wp-inst/wp-content/blogs.php?file=$2 [L]

    I have tried above below but it doesn't work. please help me on this.

About this Topic