I have a WordPress installation at mydomain.com/blogs and I have the following .htaccess
RewriteEngine On
RewriteBase /blogs/
RewriteBase /
RewriteRule ^index.php$ - [L]
ErrorDocument 404 /blogs/
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
#RewriteBase /
#RewriteRule ^index.php$ - [L]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . /index.php [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]
RewriteRule ./index.php [L]
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blogs/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blogs/index.php [L]
</IfModule>
# END WordPress
Now everything works fine, but URLs like
mydomain.com/blogs/wp-content/plugins/
mydomain.com/blogs/wp-config.php
are not redirected to the 404 correctly. It is showing a blank white page. I need these files to be redirected to the 404 page. Please help.
2
Answers
With your shown samples and attempts please try following .htaccess rules file. Apart from adding new rules added few FLAGs in to your existing rules also.
Make sure to clear your browser cache before testing your URLs.
You could force a 404 redirect: