0

.htaccess file

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} -f [or]
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^(.*)$ http://examplesite.com/vanity.php?un=$1 [NC]

php file

if(isset($_GET['un'])){

$myusername = mysqli_real_escape_string($con,$_GET['un']);


$sql="SELECT * FROM users WHERE Username='".$myusername."'";
$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) === 1){echo 'hey' . $myusername;}
}

I enter the url http://examplesite.com/john and I get http://examplesite/vanity.php?un=john with 'hey john' on page, *instead of url http://examplesite.com/john with 'hey john' on page

This is the tutorial, but I don't see where is the problem.

phillbaker
  • 1,518
  • 11
  • 22
user3944364
  • 111
  • 1
  • 2
  • 11

1 Answers1

1

That's not the way I would do my rules. Try this way.

Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /vanity.php?un=$1 [NC,L]
Panama Jack
  • 24,158
  • 10
  • 63
  • 95