我的意思是,假设我有一个用户本身的页面:localhost/blog/profile/ImUser1
我想为用户提供其他页面,例如:
localhost/blog/profile/ImUser1/my_subscribers
或者
localhost/blog/profile/ImUser1/my_posts
如何创建此类页面,例如订阅者页面?
我当前的 .htaccess 代码:
RewriteEngine On
CheckCaseOnly On
CheckSpelling On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^profile/(.*)$ /blog/profile.php?username=$1 [QSA,L]
这使我可以访问用户页面。我需要在 URL 中包含用户名,因为这就是我提取订阅者信息的方式。
到目前为止,这是我构建 PHP 的方式:
if(isset($_GET['username']) === true && empty($_GET['username']) === false){
$username = $_GET['username'];
if(user_exists($username) === true){
echo 'Welcome to '.$username.' page!';
}
}else{
echo 'Please enter a username in the URL';
}
如何调整我的 PHP 和 .htaccess 以使其正常工作?