对于单个的.htaccess重写密码保护密码保护、重写、htaccess

2023-09-02 01:06:34 作者:忘川眉

我需要一个网站的密码保护。这是一个搜索引擎友好的网址: 默认的路径是:

I need a password protection for a single site. This is a seo friendly url: The default path is:

http://www.website-url.com/index.php?id_cms=xx&controller=cms

和这里是SEO网址:

http://www.website-url.com/content/xx-login

我已经在htaccess的和。htpasswd的,但如何指定在.htaccess仅此URL重写?我想这样的:

I have already the .htaccess and .htpasswd, but how to specify rewriting in .htaccess only for this url? I tried this:

<filesMatch "http://www.website-url.com/content/xx-login">
IndexIgnore .htaccess .htpasswd
AuthUserFile /absolut_path/.htpasswd
AuthName "Login"
AuthType Basic
require valid-user
</filesMatch>

我用prestashop。

I'm using Prestashop.

推荐答案

FilesMatch不会按照这种方式,你可以尝试使用SetEnvIf之后绕过验证,除非该URI是具体的(东西是我收集你想做):

FilesMatch doesn't work that way, you could try using SetEnvIf to bypass the Auth unless the URI is something specific (which is what I gather you are trying to do):

IndexIgnore .htaccess .htpasswd

SetEnvIfNoCase Request_URI "^/content/xx-login" SECURED

# enforce auth if SECURED
AuthType Basic
AuthName "Login"
AuthUserFile /absolut_path/.htpasswd
Require valid-user
Order allow,deny
Allow from env=!SECURED
Satisfy any