Support » Fixing WordPress » pretty permalinks for attachments using htaccess

  • thinkinhurtz

    (@thinkinhurtz)


    Hi everyone I have been having trouble moving my WordPress installation to a new server. After the transfer I have everything re-enabled, unfortunately pretty permalinks for all of my media attachments seems to broken.

    Regular post permalinks are now working fine but all of my images are not visible in posts. When accessing images via the dashboard they have the URL example.com/?attachment_id=123.

    Here are some more details:

    Using version: 3.4.1
    Permalink settings: /%postname%/
    Uploads directory structure: /wp-content/uploads/year/month/file.*

    Now I am trying to get my media attachment permalinks to resemble the uploads directory as seen below.

    example.com/wp-content/uploads/year/month/file.*

    I also have the following in my .htaccess file. Need a rewrite rule to make this work, please help!

    Options -Indexes
    Options +FollowSymLinks
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # uploaded files
    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
    </IfModule>
    # END WordPress

    Thanks again everyone!

Viewing 5 replies - 1 through 5 (of 5 total)
  • thinkinhurtz

    (@thinkinhurtz)

    Still need some help please.

    Pioneer Web Design

    (@swansonphotos)

    A site link may help…

    Also please explain:

    Uploads directory structure: /wp-content/uploads/year/month/file.*

    thinkinhurtz

    (@thinkinhurtz)

    The site is in maintenance mode as things are broken. The directory listed is where my uploads are stored.

    I need a rewrite rule to redirect from:

    example.com/?attachment_id=123

    to

    example.com/wp-content/uploads/year/month/file.*

    Only for media/images/attatchments.

    Pioneer Web Design

    (@swansonphotos)

    May I ask why? Might it not be best to fix the database?

    thinkinhurtz

    (@thinkinhurtz)

    I would like things to remain as they were before the transfer. If I edit the database I would need to seek out the attatchment ID for every single image. A single rewrite rule seems simpler.

    I do not want media appearing as example.com/?attachment_id=123

    I want to see the file name.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘pretty permalinks for attachments using htaccess’ is closed to new replies.