c.fair
By:
c.fair

WordPress in Root, htaccess denies images in other directories

October 9, 2014 2.1k views

I did the Ubuntu 14 WordPress when creating my droplet. It installs into the root folder by default which has caused some problems if I want to load images from a regular directory path (e.g. /dnn/som/protocols/images/sample.jpg) on a wordpress page. The images show as missing and accessing the image url directory returns a 403 Forbidden error. How can I modify my htaccess to allow all images in a specific directory and all its subdirectories to load?

Current Htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

<IfModule mod_rewrite.c>

RewriteCond %{HTTP_COOKIE} mplk=([a-zA-Z0-9]+)
RewriteCond /wp-content/uploads/mepr/rules/%1 -f
RewriteRule ^(.*)$ - [L]

RewriteCond %{REQUEST_URI} !^/(wp-admin|wp-includes)
RewriteCond %{REQUEST_URI} !\.(php|phtml|jpg|jpeg|gif|css|png|js|ico|svg|woff|ttf|xml|PHP|PHTML|JPG|JPEG|GIF|CSS|PNG|JS|ICO|SVG|WOFF|TTF|XML)
RewriteRule . /wp-content/plugins/memberpress/lock.php [L]

</IfModule>
# 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]
</IfModule>

# BEGIN MemberPress Rules
<IfModule mod_rewrite.c>

RewriteCond %{HTTP_COOKIE} mplk=([a-zA-Z0-9]+)
RewriteCond /var/www/wp-content/uploads/mepr/rules/%1 -f
RewriteRule ^(.*)$ - [L]

RewriteCond %{REQUEST_URI} !^/(wp-admin|wp-includes)
RewriteCond %{REQUEST_URI} !\.(txt|php|phtml|jpg|jpeg|gif|css|png|js|ico|svg|woff|ttf|xml|TXT|PHP|PHTML|JPG|JPEG|GIF|CSS|PNG|JS|ICO|SVG|WOFF|TTF|XML)
RewriteRule . /wp-content/plugins/memberpress/lock.php [L]

</IfModule>

# END MemberPress Rules

# END WordPress
2 comments
  • Is the path you listed an absolute path or a path relative to your web root? If it's absolute you will need to add a directory alias in your apache configuration for this for it to be accessible.

  • Relative to web root, the WP install is in DO's default /var/www/ directory.

1 Answer
Have another answer? Share your knowledge.