不带扩展名的Realurl重写



我使用的网站运行TYPO3 6.2,扩展名为Realurl。

在树上,我创建了一个";汽车;ID为#66的页面;汽车/";作为发言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。它有效,但用户被重定向到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',
)
),
...
]

要添加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' => 'VendorUserfuncsExample->myExampleFunction',
'noMatch' => 'bypass',
),
),
),
),

在你的班级:

namespace VendorUserfuncs;
class Example {
function myExampleFunction($params, $ref) {
if ($params["decodeAlias"]) {
return ($decodedAlias));
} else {
return ($encodedAlias));
}
}
}

也许你可以尝试这样的东西:

'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编码/解码。

Florian

最新更新