arcangel Posted June 8, 2013 Share Posted June 8, 2013 I would like to know if its possible when a user log's into a directory using htaccess that the user based on the username entered it they can be redirected to there user directory using php and htaccess. For example user go's to http://blah.com/client Client enters Joe username and password for htaccess on the directory Client Joe is then redirected to http://blah.com/client/joe directory Any help is greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/278921-redirect-users-to-a-certin-directory-using-php-with-htaccess/ Share on other sites More sharing options...
denno020 Posted June 8, 2013 Share Posted June 8, 2013 If I were to do something like this, I wouldn't be using htaccess at all. Just use PHP to re-direct the user to their directory: //Get the users username by whatever means. This is a simple example of just grabbing it straight from the form POST. $username = $_POST['username']; header('Location: http://blah.com/client/'.$username); That should work fine. Quote Link to comment https://forums.phpfreaks.com/topic/278921-redirect-users-to-a-certin-directory-using-php-with-htaccess/#findComment-1434800 Share on other sites More sharing options...
requinix Posted June 8, 2013 Share Posted June 8, 2013 Be sure to require the login for /client/joe too. Quote Link to comment https://forums.phpfreaks.com/topic/278921-redirect-users-to-a-certin-directory-using-php-with-htaccess/#findComment-1434801 Share on other sites More sharing options...
arcangel Posted June 8, 2013 Author Share Posted June 8, 2013 Thanks So i would just add that into the index.php file for each user that i wanted to redirect to a directory? Quote Link to comment https://forums.phpfreaks.com/topic/278921-redirect-users-to-a-certin-directory-using-php-with-htaccess/#findComment-1434848 Share on other sites More sharing options...
arcangel Posted June 8, 2013 Author Share Posted June 8, 2013 ok i see what your daying create a login page then include that and not use htaccess that seems to work out better Thanks Quote Link to comment https://forums.phpfreaks.com/topic/278921-redirect-users-to-a-certin-directory-using-php-with-htaccess/#findComment-1434867 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.