开发者

Password protect directory with .htaccess

I've got a wordpress multisite install that has a host of sub-sites in dynamic/virtual folders. For example, http://www.my开发者_运维问答site.com/ is the main root dir, with a sub-site sitting dynamically in http://www.mysite.com/subsite/. Now, the sub-directory 'subsite' doesn't physically exist but is created by wordpress.

I would like to know if it's possible to protect one of these directories that doesn't physically exist using .htaccess/.htpasswd?

I've tried creating a physical version of the directory, but it then breaks my wordpress installation.

I just need a line of code in the .htaccess that tells it which folder it should be targeting/protecting rather than having to actually place it in the directory.

Hope this makes sense, any help appreciated, S.


AFAIK, you cannot use .htaccess for virtual paths handled by web apps.

I'm not a wordpress user, but there seem to be several wordpress plugins that allow you to password protect your wordpress site.

  • http://wordpress.org/extend/plugins/http-authentication/
  • http://wordpress.org/extend/plugins/askapache-password-protect/
  • http://wordpress.org/extend/plugins/wp-password/
  • (and many more...)


I think what you are trying to do probably is related to my issue with wp-admin security via .htaccess / htpasswd.

The virtual directory authentication does not happen due to the WP rewrite rules for the MU/Network config.

You should be able to do something similar to the solution I used.

http://howden.net.au/thowden/2011/03/wordpress-404-error-password-admin-directory/

The issue with answer #1 is that all of the htaccess / htpasswd related setups, whether a WP plugin or manually done by the site admin or done via cpanel / plesk assume that it is not a virtual directory. The rewrite rules for the virtual directory kills the htpasswd option.


Eventually I found that Password Protected is simple and effective if you just want to protect the (sub)site with a generic password, without creating a bunch of users.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜