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
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hello,
Just an update to this one for anyone who comes across this in 2022.
Here is a default Apache Vhost that you could use with most WordPress installations:
<VirtualHost *:80>
ServerName your-domain.com
ServerAlias www.your-domain.com
DocumentRoot /var/www/html/your-domain.com
<Directory /var/www/html/your-domain.com>
Require all granted
# Allow local .htaccess to override Apache configuration settings
AllowOverride all
</Directory>
# Enable RewriteEngine
RewriteEngine on
RewriteOptions inherit
# Block .svn, .git
RewriteRule \.(svn|git)(/)?$ - [F]
# Recommended: XSS protection
<IfModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
Header always append X-Frame-Options SAMEORIGIN
</IfModule>
</VirtualHost>
Alternatively, you can use the following 1-Click installation for new WordPress websites:
https://marketplace.digitalocean.com/apps/wordpress
Best,
Bobby
This comment has been deleted
Click below to sign up and get $100 of credit to try our products over 60 days!
Relative to web root, the WP install is in DO’s default /var/www/ directory.
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.