2014-12-05 44 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错误