How to authenticate specific single page/URL in .htaccess and Codeigniter?

谁都会走 提交于 2021-02-11 13:52:48

问题


This is my .htaccess file

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 
RewriteRule ^([^\.]+)$ $1.php/$1 [L] 
</IfModule>

AuthType Basic
AuthName "Restricted Content"
AuthUserFile .htpasswd
Require valid-user

I have Add htaccess authentication only for this URL "welcome/list" no another all pages/URLs


回答1:


#Set an environment variable for the URI you want to handle
SetEnvIf Request_URI "/welcome/list" welcome_list

AuthName "Restricted Content"
AuthType Basic
AuthUserFile .htpasswd

Order Allow, Deny
Satisfy any
Allow all
Require valid-user

#Handle case 
Deny from env=welcome_list


来源:https://stackoverflow.com/questions/61931993/how-to-authenticate-specific-single-page-url-in-htaccess-and-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!