未找到使用htpassword保护子目录Wordpress的返回页



我按照这个指令来保护子目录。https://support.hostgator.com/articles/wordpress-preventing-you-from-password-protecting-a-directory

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

已更改为

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./ /index.php [L]
</IfModule>
# END WordPress

它可以在不返回404页面的情况下保护Wordpress中的子目录,但似乎网站链接无效。

示例。网站返回的错误页面是它在域的末尾没有斜杠。

工作域:http://demodomain.com/something/

不工作域:http://demodomain.com/something

在RewriteEngine On下面尝试以下选项规则:

1) RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/$ /$1 [R=302,NE,L]
2) #Removing trailing slash
RewriteRule ^(.*)/$ /$1 [L,R]

在URL 末尾添加斜线

RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301]

或者遵循

# Ensure all URLs have a trailing slash.
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.example.com/$1/ [L,R=301]

最新更新