Applicable to:
- Plesk Onyx for Linux
Question
How to restrict the direct access to wp-admin?
Answer
Create a rewrite rule in .htaccess as the following:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
# Fix using the previous answer.
RewriteRule ^admin/(.*)$ wp-admin/$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
#Fix to load css js image files for multi site admin urls.
#old code RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.(php|css|js|png|jpg|gif))$ $1 [L]
RewriteRule . index.php [L]
Comments
0 comments
Please sign in to leave a comment.