WordPress.org

Ready to get started?Download WordPress

Forums

pretty permalinks for attachments using htaccess (6 posts)

  1. thinkinhurtz
    Member
    Posted 1 year 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.

    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!

  2. thinkinhurtz
    Member
    Posted 1 year ago #

    Still need some help please.

  3. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    A site link may help...

    Also please explain:

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

  4. thinkinhurtz
    Member
    Posted 1 year 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:

    example.com/?attachment_id=123

    to

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

    Only for media/images/attatchments.

  5. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

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

  6. thinkinhurtz
    Member
    Posted 1 year 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