2013-03-17 36 views
0

出於某種原因,我收到虛榮URL錯誤,並且其他帖子沒有充分回答該問題。 PHP代碼有什麼問題?虛榮URL錯誤:找不到對象

if (isset($_GET['username']) === true && empty($_GET['username']) === false) { 
$username = $_GET['username']; 
echo $username; 
} 

和我.htaccess文件是:

Options +FollowSymLinks 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /lr/profile.php?username=$1 

如果我去/projects/lr/profile.php?username=harrison7042,它的工作原理,但如果我去/projects/lr/harrison7042它不工作,只是返回:Object not found!

如果我改變這一行:

RewriteRule ^(.*)$ /lr/profile.php?username=$1 

要這樣:

RewriteRule ^(.*)$ projects/lr/profile.php?username=$1 

服務器返回一個Internal Server Error。我不確定我做錯了什麼,或者是什麼。我完全遵循教程here

感謝, 哈里森

+0

'未找到對象'從你的腳本來!我們沒有辦法幫助你,因爲你沒有顯示它背後的代碼。做一個'print_r($ _ GET)'然後告訴我們。否則,我們通常只能用重寫規則來幫助你。 – Brad 2013-03-17 04:31:07

+0

@Brad我無法獲得項目/ lr/harrison7042上的print_r($ _GET)或任何用戶名,但在項目/ lr/profile.php上?username = harrison7042我得到「Array([username] => harrison7042)」 。 – 2013-03-17 04:39:39

+0

@Brad如果我跟着視頻,會出現什麼問題。 – 2013-03-17 04:45:45

回答

0

在.htaccess變化:

RewriteRule ^(.*)$ /lr/profile.php?username=$1 

RewriteRule ^(.*)$ profile.php?username=$1