I have read a few articles on rewriting using .htaccess and I still cannot fully get the outcome I was hoping for.
I have a url called: sitename.co.nf/Profile.php?u=Admin
Admin is my username. I want to know how to rewrite the url as sitename.co.nf/$username
$username is a variable I have set up in my PHP code.
I tried using this rewrite without luck RewriteRule ^([a-zA-Z0-9_\-]+)/?$ Profile.php?u=$1
Here is some other userful code you may want to see...
if (isset($_GET['u'])) {
$username = mysqli_real_escape_string($connect, $_GET['u']);
if (ctype_alnum($username)) {
//check user exists
$check = mysqli_query($connect, "SELECT username FROM users WHERE username='$username'");
if (mysqli_num_rows($check)===1) {
$get = mysqli_fetch_assoc($check);
$username = $get['username'];
}