簡體   English   中英

如何使用htaccess發送多個$ _GET [“ x”]變量?

[英]How can I send multiple $_GET[“x”] variables using htaccess?

到目前為止,一切都很好,但是.....

$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美元? 我在構建自定義鏈接的方式上有問題嗎?

不能確定您真正想要的是什么,但是如果您想在其中使用變量,這就是您使用雙引號而不是單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>";

Havent測試了它,但是應該可以解決問題

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

請注意,這可能會使您陷入無盡的循環並產生500錯誤

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM