问题原文
原帖链接 · evachristine · CC BY-SA 3.0
We have an apache 2.2 install with this config on an Ubuntu 12.04:
cat /etc/apache2/sites-enabled/000-default
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
AuthType Basic
AuthName "Please provide USERNAME AND PASSWORD!"
AuthBasicProvider ldap
Order allow,deny
Allow from all
AuthLDAPURL "ldap://foo.com/c=uk,ou=bar,o=foo.com?mail"
Require valid-user
Require ldap-attribute dept=4F4623
Require ldap-attribute emailAddress=[email omitted]
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel info
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
</VirtualHost>
It's working great with LDAP auth! We have ldap-utils, php5, apache2.2-common.
Question:
How can we create a page, so for example:
somedomain.com/selectorpage.html
redirects the logged in user to another page based on their username?
So if XY user visits the "selectorpage.html", then it will be redirected immediately to page XY.html. If AB user visits the "selectorpage.html", then it will be redirected immediately to page AB.html. Or are there any apache redirects for this?
社区高分解答
原帖链接 · Jonathan · CC BY-SA 3.0
combining this post with your information, Id suggest you use a php page, instead of an html page in place of selector page.html, and using
$_SERVER['PHP_AUTH_USER']
inside the selector_page.php with either:
switch($_SERVER['PHP_AUTH_USER']){
case "user_a":
$url = "xy.html";
break;
......
case "user_n":
$url = "nn.html";
break;
default:
$url = "ab.html";
break;
}
header("location: $url");
or similar
( you might need to do a mod_rewrite rule to change the selectorpage.html to selectorpage.php if its an external link and not under your control, but it would be better to change the link to point to the php page if its not )
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
