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?我在构建自定义链接的方式上做错了吗?

4

1 回答 1

1

不确定你真正想要什么,但如果你想在其中使用变量,这就是创建有效链接的方式,使用双引号而不是单引号。

$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 错误

于 2014-12-05T23:02:04.250 回答