Support » Fixing WordPress » Images break using permalinks & .htaccess in WP 2.6 mod_rewrite generates wrong

  • 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]

    # 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:

    Actual path to image:

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)

    (@otto42) Admin

    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="" />

    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.

    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.


    Thanks loads 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Images break using permalinks & .htaccess in WP 2.6 mod_rewrite generates wrong’ is closed to new replies.