Can I use .htpasswd to protect a nonexistent directory (mod_rewrite virtual directory)?

I use the front controller template and therefore all requests are routed through my index.php file. I would like to provide an Admin controller (available in mysite / admin /) using .htpasswd. The only problem is that "admin" is not a directory, but simply mod_rewrite. It can be done?

+4
source share
1 answer

There is more than one way, I am sure. You can create access control using mod_rewrite and [F] according to any criteria that you would define. See, for example, Access Control with mod_rewrite . That says you can do it.

 <Location /admin> [here your rules] </Location> 

Require for context , which means you can use it in context

 <Directory>, <Location>, <Files>, and <Proxy> 

:)

+2
source

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


All Articles