0

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.

2 Answers2

1

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>
larsks
  • 41,276
  • 13
  • 117
  • 170
-1

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

iiegn
  • 304
  • 2
  • 3
  • 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