修改错误编码组件的 Joomla sef URL

modify the Joomla sef URLs for a bad coded component

大家好,今天一位客户带着已经 运行 Joomla!站点,他们在此站点上有一些自定义内容,并且是通过直接在某些页面中使用 PHP 代码来完成的,结果是只有一个 Joomla!页面,当使用 GET 参数请求时显示不同的内容。 网址是这样的:

www.example.com/catalog/product-category/product-details.html?intid=1234&name=889-abc-456

我想要获得的 URL 如下:

www.example.com/catalog/product-category/product-details/1234/889-abc-456/

我想通过编辑 .htaccess 文件来获得它,以避免触及网站的代码。

考虑到 .htacces 已被 Joomla! ?

实际上,我有这样的东西:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|POST|HEAD)\ /product-details\.html\?intid=([^&]+)&name=([^&\ ]+)
RewriteRule ^ /product-details/%2/%3/? [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?product-details/([^/]+)/([^/]+)/?$ /product-details.html?intid=&name= [L]

为 Joomla URL 编辑 htaccess 文件不是一个好主意。您可以查看组件的路由器文件,而不是在 htaccess 中进行更复杂的更改。在此处查看更多详细信息 https://docs.joomla.org/Supporting_SEF_URLs_in_your_component