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.

4

1 回答 1

1

这不是我遵守规则的方式。试试这个方法。

Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /vanity.php?un=$1 [NC,L]
于 2015-03-18T13:54:49.640 回答