我在www.example.com安装了一个WordPressmydomain.com/blogs,并且我有以下.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
现在一切正常,但像
mydomain.com/blogs/wp-content/plugins/
mydomain.com/blogs/wp-config.php
没有被正确地重定向到404。它显示一个空白的白色页面。我需要这些文件被重定向到404页面。请帮助。
2条答案
按热度按时间z5btuh9x1#
使用您显示示例和尝试,请尝试以下.htaccess规则文件除了添加新规则外,还在现有规则中添加了一些标志
请确保在测试URL之前清除浏览器缓存。
vecaoik12#
您可以强制进行404重定向: