• Hi,

    I have multisite set up (subfolder) and want to user htaccess basic authentication to validate a few key users. Once these have been validated I want to then redirect them to their wordpress site and, if they try to go to a different place (like the root) push them back to where they should be again.

    Can anyone please advise what needs to go in the htaccess to achieve this? I’ve tried several combinations of user and uri but can’t seem to get it to work and keep the styles working in the relevant themes.

    My current htaccess is:

    AuthType Basic
    AuthName “realm”
    AuthUserFile /path/to/.htpasswd
    Require valid-user

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]

    # uploaded files
    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ – [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    # individual user redirects
    RewriteCond %{REMOTE_USER}% ^username$
    RewriteCond %{REQUEST_URI}% !^/user_url/.*$
    RewriteRule . /user_url/ [R=301,L]

    I’m sure this is easy but I’m a complete newbie to both WordPress and mod_rewrite!

    Thanks,

    Adam M.

  • The topic ‘htaccess user redirect’ is closed to new replies.