虚荣 url 不起作用
Vanity url don't work
.htaccess 文件
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} -f [or]
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^(.*)$ http://examplesite.com/vanity.php?un= [NC]
php 文件
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;}
}
我在页面
输入urlhttp://examplesite.com/john and I get http://examplesite/vanity.php?un=john with 'hey john' on page, *instead of url http://examplesite.com/john和'hey john'
这是 tutorial,但我看不出问题在哪里。
这不是我遵守规则的方式。试试这个方法。
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /vanity.php?un= [NC,L]
.htaccess 文件
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} -f [or]
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^(.*)$ http://examplesite.com/vanity.php?un= [NC]
php 文件
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;}
}
我在页面
输入urlhttp://examplesite.com/john and I get http://examplesite/vanity.php?un=john with 'hey john' on page, *instead of url http://examplesite.com/john和'hey john'这是 tutorial,但我看不出问题在哪里。
这不是我遵守规则的方式。试试这个方法。
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /vanity.php?un= [NC,L]