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=someone@somewhere.com

    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 ::1/128
    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/apache.crt
    SSLCertificateKeyFile /etc/apache2/ssl/apache.key

It's working great with LDAP auth! We have ldap-utils, php5, apache2.2-common.


How can we create a page, so for example:


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?

  • 1
    Only an idea, I've not tried this: Set the REMOTE_USER variable to the logged-in user (AuthLDAPRemoteUserAttribute could help), and then use mod_rewrite to redirect: Use a condition RewriteCond %{REMOTE_USER} (.*) to get the user name, and redirect using a backreferencing rewrite-rule after that: RewriteRule .* /%1.html, where %1 will be replaced with the username. – Jost May 10 '14 at 17:42

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


inside the selector_page.php with either:

    case "user_a":
        $url = "xy.html";
    case "user_n":
        $url = "nn.html";
        $url = "ab.html";
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 )

| improve this answer | |
  • if you have 100 users do you need add 100 urls and cases? – Baha Mar 23 '19 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.