Password Protecting a Virtual Directory Using .htaccess

I have a site with a virtual directory structure, such as mysite.com/folder/titleone that actually rewrites .htaccess to mysite.com/f/index.php?p=title. I want to password protect a folder folderwith .htaccess and know how to do this with actual folders. But I do not want the password to protect the main site mysite.com, and right now, if I put the .htaccess file in a directory mysite.com, I protect mysite.comand mysite.com/folder. I also tried to protect mysite.com/f.

How to protect only mysite.com/folderwith .htaccess?

EDIT: Added .htaccess content mysite.com.

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^folder/(.*)$ /f/index.php?p=$1 [PT,L,QSA]
RewriteRule ^folder/*$ /f/index.php [L,QSA]

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

.htaccess , mysite.com/f. mysite.com, , . , 404, .

AuthName "Restricted Area" 
AuthType Basic 
AuthUserFile /home/myusername/.htpasswd 
require valid-user
+3
3

...

, , , , .

, .

document_root/.htaccess domain.com/wiki domain.com/w ( ? lol):

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

document_root/wiki/.htaccess wiki :

AuthType Basic
AuthName "Restricted"
AuthUserFile "/home/user/.htpasswds/public_html/wiki/passwd"
require valid-user

document_root/.htaccess, :

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

domain.com , domain.com/wiki .

, - .

+1

, ( ), - "" ( ) .htaccess.

0

, Apache 2.2

... ,

... : mysite.com/f/.htaccess .

, .

0

Source: https://habr.com/ru/post/1763861/


All Articles