Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have the following .htaccess file (usual one for MediaWiki):

RewriteEngine On
RewriteRule ^wiki/(.*)$ /w/index.php?title=$1 [PT,L,QSA]
RewriteRule ^wiki/*$ /w/index.php [L,QSA]
RewriteRule ^/*$ /w/index.php [L,QSA]

And I want to restrict access to some paths (e.g. ^wiki/Private/(.*)$) with the password.

Is there any possibility to do that using .htaccess? There is no /wiki/ directory, so it isn't possible to put .htpasswd inside it.

Thank you.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

You would typically do this using <Location> directives, but these can only be specified in your server configuration (i.e., not in .htaccess files). Is there a particular reason you're trying to do this with a .htaccess file?

For example:

RewriteEngine On
RewriteRule ^wiki/(.*)$ /w/index.php?title=$1 [PT,L,QSA]
RewriteRule ^wiki/*$ /w/index.php [L,QSA]
RewriteRule ^/*$ /w/index.php [L,QSA]

<Location /wiki/Private/>
    # put your auth configuration here
</Location>
share|improve this answer
    
Yes, it isn't my own server but web hosting. –  Nikolay Vyahhi Nov 23 '10 at 20:38

you could use something like:

<AuthnProviderAlias file yourfile-htpasswd>
        AuthUserFile    /somedir/htpasswd
</AuthnProviderAlias>

in a server configuration file to assign an alias for an authentication provider. then, something like:

AuthBasicProvider yourfile-htpasswd
AuthName "Temporary Login"
AuthType Basic
require valid-user

in a .htaccess file (in Private) should work.

see: http://httpd.apache.org/docs/2.2/mod/mod_authn_alias.html

share|improve this answer
    
OP indicated that the filesystem does not correspond to the URL structure so there is no "Private" directory into which one would put a .htaccess file. –  larsks Nov 23 '10 at 14:54
    
hm, point taken - if there is no wiki, no Private, no other real directory at all then there is no .htaccess file covering the case. –  iiegn Nov 23 '10 at 15:04
    
That's why the question was asked ;) There's no real directory — only path alias which I want to make private. –  Nikolay Vyahhi Nov 23 '10 at 20:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.