我正在使用一个运行Realurl扩展的TYPO3 6.2的网站。
在树中,我创建了一个ID #66的"Cars“页面,并使用"cars/”作为语音url路径段。我的页面现在可以使用https://www.mywebsite.com/cars/了。凉爽的。
如果使用https://www.mywebsite.com/cars/audi,我需要的是在Typoscript中检索audi作为GET变量(GP:car_brand),但是当前的Typo3默认行为是在现有的cars页面下面搜索audi页面.然后显示404错误。
我已经尝试过的是:
1/在.htaccess:RewriteRule ^cars/(.*)$ /index.php?id=66&car_brand=/$1 [P]中添加一个RewriteRule ^cars/(.*)$ /index.php?id=66&car_brand=/$1 [P]。它可以工作,但是用户被重定向到https://www.mywebsite.com/cars/?car_brand=audi,我们确实需要保持cars/audi/ URL方案更符合SEO /用户友好。
2/在我的realurl_conf.php postVarSets中添加自定义配置,但是realurl很难理解,而且我没有处理它的技术技能:
<?php
'postVarSets' => [
66 => array(
array(
'GETvar' => 'car_brand',
'valueMap' => array(
'no-comments' => 1
),
'noMatch' => 'bypass',
)
),
...
]发布于 2020-09-28 12:15:41
要添加一个userFunc,请查看以下内容:
https://github.com/dmitryd/typo3-realurl/wiki/Configuration-reference#userfunc
在realurl_conf.php中:
'postVarSets' => array(
'66' => array(
'brand' => array(
array(
'GETvar' => 'car_brand',
'userFunc' => 'Vendor\Userfuncs\Example->myExampleFunction',
'noMatch' => 'bypass',
),
),
),
),在你们班:
namespace Vendor\Userfuncs;
class Example {
function myExampleFunction($params, $ref) {
if ($params["decodeAlias"]) {
return ($decodedAlias));
} else {
return ($encodedAlias));
}
}
}发布于 2020-09-25 08:00:27
也许你可以试试这样的方法:
'postVarSets' => array(
'66' => array(
'brand' => array(
array(
'GETvar' => 'car_brand',
'noMatch' => 'bypass',
),
),
),
),所以URL将如下所示
https://www.mywebsite.com/cars/brand/audi
也许fixedPostVars也有避免“品牌”部分的解决方案,但在这种情况下,get参数'?car_brand=xxx‘必须始终设置,所以我认为不可能只有:https://www.mywebsite.com/cars。
或者另一个解决方案是使用userFunc,然后您可以管理自己的URL编码/解码。
佛里安
https://stackoverflow.com/questions/64059400
复制相似问题