pretty permalinks for attachments using htaccess (6 posts)

  1. thinkinhurtz
    Posted 3 years ago #

    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.


    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]
    # END WordPress

    Thanks again everyone!

  2. thinkinhurtz
    Posted 3 years ago #

    Still need some help please.

  3. Pioneer Web Design
    Posted 3 years ago #

    A site link may help...

    Also please explain:

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

  4. thinkinhurtz
    Posted 3 years ago #

    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:




    Only for media/images/attatchments.

  5. Pioneer Web Design
    Posted 3 years ago #

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

  6. thinkinhurtz
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic