htaccess授权排除URL

时间:2015-02-04 06:56:22

标签: php apache .htaccess cron

请问,你能解决我的问题吗?我一直在寻找很多exmaples(也就是这个:htaccess exclude one url from Basic Auth),但我还是无法让它工作:/ 我有网址smth.com/databox_sync,我想从htaccess验证中排除这个网址。我的htaccess看起来像这样:

    AuthUserFile /var/www/clients/client1/web3/web/domains/akomin.cz/.htpasswd
    AuthType Basic
    AuthName "My restricted Area"

        # set an environt

ment variable "noauth" if the request starts with "/callbacks/"
    SetEnvIf Request_URI ^databox_sync noauth=1

    Order Deny,Allow
    Satisfy any
    Deny from all
    Require valid-user
    Allow from env=noauth

    RewriteEngine on
    #RewriteRule ^(.*)$ /Symfony/web/$1 [L,NE]

    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]


    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]

我通过cron调用此地址但cron返回:

  

"此外,需要401授权...."

1 个答案:

答案 0 :(得分:0)

将您的SetEnvIf行更改为:

SetEnvIf Request_URI ^/(databox_sync|index\.php$) noauth=1

这是因为您在最后一条规则中将所有内容都路由到index.php,因此databox_sync也会路由到它。