2014-12-05 46 views
0

到目前爲止一切良好,這可是.....

$custom_path= "musical_instruments"; 
echo '< a href='$custom_path' >custom link< /a>' 

我可以在頁面中使用$_GEt["custom_path"]我重定向

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ localhost/folder/folder/stuff.php?custom_path=$1 

如何發送多個$_GET變量形成一個自定義鏈接,以便我可以在我重定向到的頁面中使用它們?

我做到了這一點,但不是很我想知道:

$custom_path = "category=$category&item_name=$url&item_id=$id"; 

PHP

$custom_path= "musical_instruments"; 
$item_name= "guitar"; 
$item_id= 123; 

echo '< a href='$custom_path&$item_name&$item_id' >custom link< /a>' 

htaccess的

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ localhost/folder/folder/stuff.php?custom_path=$1&item_name=$2&item_id=$3 

我如何可以訪問變量$ 1 ,2美元和3美元的自定義鏈接?我在做自定義鏈接的方式做錯了什麼?

+1

使用某物像'^(。*) &(。*)&(。*)$''如果你想使用'&'作爲分隔符,但是標準是使用'/'而不是 – kero 2014-12-05 22:37:57

+2

你的回顯行是無效的php – 2014-12-05 22:48:22

+0

你能告訴我如何正確地建立一個自定義鏈接訪問它與htaccess文件? – nero 2014-12-05 22:52:38

回答

1

不知道你真的想用這個,但這是你如何創建一個有效的鏈接 如果你想使用它裏面的變量使用雙引號而不是單個qoutes。

$custom_path= "musical_instruments"; 
$item_name= "guitar"; 
$item_id= 123; 

echo "< a href='?custom_path=$custom_path&item_name=$item_name&item_id=$item_id'>custom link< /a>"; 

還沒有測試,但這個應該做的伎倆

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !stuff\.php$ 
RewriteRule ^(.*)$ /folder/folder/stuff.php?%{QUERY_STRING} [L] 

小心,這可能讓你在無限循環併產生一個500錯誤