我正在尝试根据经过身份验证的用户重写 URL。但 REMOTE_USER 始终为空。身份验证有效。
我很困惑...我遗漏了什么吗?
RewriteEngine On
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 3
<Directory /home/storage>
Order Allow,Deny
Allow from all
Dav On
Options Indexes
AllowOverride None
AuthName "Webdav: insert your username and password"
AuthType Basic
AuthBasicProvider ldap
AuthLDAPBindDN cn=adsyncldapagent,ou=Service,ou=AdminUsers,ou=ITS,dc=xx,dc=xx
AuthLDAPBindPassword xxxx
AuthzLDAPAuthoritative On
AuthLDAPURL "ldap://xxxx/ou=Staff,ou=AUM,dc=xx,dc=xx?sAMAccountName?sub"
<LimitExcept GET POST>
Require valid-user
</LimitExcept>
</Directory>
RewriteCond %{REQUEST_URI} ^/webdav
RewriteRule . /home/storage/%{LA-U:REMOTE_USER}p
这是重写日志:
::1 - - [07/Mar/2013:20:26:17 +0100] [localhost/sid#7faeae695fe8][rid#7faeae766368/subreq] (2) init rewrite engine with requested uri /webdav
::1 - - [07/Mar/2013:20:26:17 +0100] [localhost/sid#7faeae695fe8][rid#7faeae766368/subreq] (3) applying pattern '.' to uri '/webdav'
::1 - - [07/Mar/2013:20:26:17 +0100] [localhost/sid#7faeae695fe8][rid#7faeae766368/subreq] (2) rewrite '/webdav' -> '/home/storage/p'
答案1
您没有配置任何身份验证,因此在触发/webdav
此操作时RewriteRule
是否REMOTE_USER
。您需要使用/webdav
与保护 相同的身份验证配置进行保护/home/storage
。
像这样:
<Directory /home/storage>
AuthName "WebDAV"
AuthType Basic
AuthBasicProvider ldap
AuthzLDAPAuthoritative On
AuthLDAPURL "ldap://xxxx/ou=Staff,ou=AUM,dc=xx,dc=xx?sAMAccountName?sub"
</Directory>
<Location /webdav/>
AuthName "WebDAV"
AuthType Basic
AuthBasicProvider ldap
AuthzLDAPAuthoritative On
AuthLDAPURL "ldap://xxxx/ou=Staff,ou=AUM,dc=xx,dc=xx?sAMAccountName?sub"
</Location>
RewriteRule ^/webdav/(.*) /var/www/webdav/%{LA-U:REMOTE_USER}/$1