WordPress.org

Forums

Images break using permalinks & .htaccess in WP 2.6 mod_rewrite generates wrong (3 posts)

  1. Papa-Raboon
    Member
    Posted 6 years ago #

    Please can someone help. I am a newbie to both wordpress and mod_rewrite.

    I have set up custom permalinks like this: /%category%/%postname%/

    I have also set up my .htaccess file like so:

    Options +Indexes +FollowSymlinks
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /wordpress/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /wordpress/index.php [L]
    </IfModule>

    # END WordPress

    Now the new clean URLs work fine for the posts and pages, no problem at all, but images I have set up in the site are broken.

    Basically the URLs to the images have additional pseudo directories in their paths like the following example.

    Mod_rewrite generated path:
    http://www.aztec360.co.uk/wordpress/welcome-to-our-new-blog/wp-content/themes/black-splat-wr/images/aztec_banner.png

    Actual path to image:
    http://www.aztec360.co.uk/wordpress/wp-content/themes/black-splat-wr/images/aztec_banner.png

    I'm guessing I need to modify the .htaccess file a bit but have no idea how. And I didn't write the original .htaccess file either. I found it on the web.

    Any ideas please wordpress gurus?

    Cheers in advance
    Paul Randall.

  2. When you use images, you can NOT use relative paths. Use absolute paths instead. There is no fix except to go back and fix all your posts and theme and such to have the full paths to the files.

    That is, instead of this:
    <img src="wp-content/uploads/whatever.png" />

    You should have done this:
    <img src="http://www.aztec360.co.uk/wordpress/wp-content/uploads/whatever.png" />

    That would be in a post, of course. In a theme, you are supposed to do things like this:
    <img src="<?php bloginfo('stylesheet_directory'); ?>/images/aztec_banner.png" alt="Aztec Internet" />

    That "bloginfo('stylesheet_directory');" always gives the path to your current theme's directory.

  3. Papa-Raboon
    Member
    Posted 6 years ago #

    Hey thanks Otto. At least I know now the limitations of images using mod_rewrite.

    Even if it means I have to footle around with my paths.

    Sweet.

    Thanks loads :-)

Topic Closed

This topic has been closed to new replies.

About this Topic