jamesmpollard Posted October 29, 2015 Share Posted October 29, 2015 I was wondering if someone could shed some light on where I'm going wrong here. I'm trying to make it so that if a user came to my site (in dev mode at the minute so localhost) and used the url for example http://localhost/example/aquery/string. The url it would actually access it http://localhost/example.php?route=aquery/string. Is this possible? Here's what I have so far... Options All -Indexes +FollowSymLinks +MultiViews RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*?)/(.*)$ $1.php?route=$2 [L] DefaultType application/x-httpd-php Any help appreciated. Many thanks James Quote Link to comment https://forums.phpfreaks.com/topic/298917-htaccess-help-needed/ Share on other sites More sharing options...
jamesmpollard Posted October 29, 2015 Author Share Posted October 29, 2015 Sorry about the wrong category. Mod could you move it for me please? Quote Link to comment https://forums.phpfreaks.com/topic/298917-htaccess-help-needed/#findComment-1524743 Share on other sites More sharing options...
QuickOldCar Posted October 30, 2015 Share Posted October 30, 2015 Rewrites are not for multiple user modes, it's for using the same values each time, modifying the url address versus the actual location. Your best bet is to include different scripts or permission rights with code. Use a session to see if that person has at least a certain permission level User permissions 1-9 stored in database Always use session_start(); top your scripts Upon successful login when you do a query set the permission in the session $_SESSION['permission'] = $row['permission']; Now in your script can check if a permission is higher than a certain amount. if($_SESSION['permission'] && $_SESSION['permission'] >= { //allow something a superadmin can do } You can also do some functions to make it simpler writing throughout your code. Can expand upon this with specific roles hard coded or saved database <?php session_start(); //set session with login query $_SESSION['permission'] = 9; //1-9 //permissions based on at least a certain number function isUberAdmin() { if ($_SESSION['permission'] && $_SESSION['permission'] == 9) { return true; } else { return false; } } function isSuperAdmin() { if ($_SESSION['permission'] && $_SESSION['permission'] >= { return true; } else { return false; } } function isAdmin() { if ($_SESSION['permission'] && $_SESSION['permission'] >= 7) { return true; } else { return false; } } function isUberModerator() { if ($_SESSION['permission'] && $_SESSION['permission'] >= 6) { return true; } else { return false; } } function isSuperModerator() { if ($_SESSION['permission'] && $_SESSION['permission'] >= 5) { return true; } else { return false; } } function isModerator() { if ($_SESSION['permission'] && $_SESSION['permission'] >= 4) { return true; } else { return false; } } function isUberUser() { if ($_SESSION['permission'] && $_SESSION['permission'] >= 3) { return true; } else { return false; } } function isSuperUser() { if ($_SESSION['permission'] && $_SESSION['permission'] >= 2) { return true; } else { return false; } } function isUser() { if ($_SESSION['permission'] && $_SESSION['permission'] >= 1) { return true; } else { return false; } } function isLoggedIn() { if ($_SESSION['permission'] && $_SESSION['permission'] != "") { return true; } else { return false; } } //simple usage if (isAdmin()) { echo " are admin"; } else { echo " not admin"; } if (isLoggedIn()) { echo " are logged in"; } else { echo " not logged in"; } if (isUser()) { echo " are at least a user"; } else { echo " not even a user"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/298917-htaccess-help-needed/#findComment-1524778 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.