的.htaccess code,以保护单一的网址是什么?网址、htaccess、code

2023-09-02 20:37:35 作者:村姑也狠潮丶

是否有可能来保护通过的.htaccess 一个URL?例如,我将有 website.com/index.php?skin=name 。我可以使用密码保护仅此网址是什么? (没有PHP的变化,只有的.htaccess

Is it possible to protect a single URL through .htaccess? For example I will have website.com/index.php?skin=name. Can I password protect only this url? (with no PHP changes, only .htaccess)

website.com/index.php website.com/index.php?skin=other_name 不应该受到限制。

推荐答案

您可以重写的地址,以保护它是这样的:

You can rewrite the address to protect it like this:

RewriteEngine On
RewriteCond %{REQUEST_URI}  ^/index.php$
RewriteCond %{QUERY_STRING} ^skin=(name)$
RewriteRule ^(.*)$ /skin/%1 [PT]

<LocationMatch "/skin/name">
     AuthType Basic
     AuthName "By Invitation Only"
     AuthUserFile /path/to/passwords
     Require valid-user
</LocationMatch>