我有一个Joomla 3.3.6
(编辑:3.5.
)网站仅分为 3 层:
- 四大类(i、ii、iii、iiii)
- 每个类别都分为一些中间类别(A、B、C……)
- 最后是文章
- 两种语言(en、pt)
The URL
设置后Search Engine Friendly URLs
, Use URL rewriting
, Adds Suffix to URL
and multilanguage support
, should采用以下形式:
http://www.example.com/en/bigcatiii/intercatA/articlex.html
但正如许多其他安装了 Joomla 并自 Joomla-Baby-Version 以来寻求解决方案的人一样,我得到了:
http://www.example.com/en/bigcatiii/666-intercatA/articlex.html
其中 666 是一个来自地狱的数字,表示毫无目的类别ID
现在浏览答案,我找到了这个答案:
Edit “components/com_content/router.php“
(You’ll probably have to re-do this step every time you update Joomla.)
Replace the lines 38 and 290 with:
$advanced = $params->get('sef_advanced_link', 1);
and Replace line 426 with
->where($db->quoteName(‘alias’) . ‘ = ‘ . $db->quote($segment));
嗯,首先,第 426 行已经像原来的那样了。其次,这并不能解决问题。它适用于:
http://www.example.com/en/bigcatiii/intercatA/articlex.html
但它打破了智慧404如果您浏览到以下位置,则会出现错误:
http://www.example.com/en/bigcatiii/intercatA.html
另外,我注意到ID数字不同。虽然整个 URL 是
http://www.example.com/en/bigcatiii/666-intercatA/articlex.html
同类别描述页面是
http://www.example.com/en/bigcatiii/333-intercatA.html
还有另一种解决方案听起来更好,但也不起作用,基于.htaccess
RewriteEngine on
RewriteBase /
RewriteRule (\d+)-([^/]*) $2 [R=301,L]
The URLs
显示正常,但找不到页面。如果我们能提供一个解决方案,那就更好了.htaccess而不是改变 Joomla 核心。
不过,如果其他谷歌搜索的建议有效的话,更改 Joomla 核心就可以了。
Copy “components/com_content/router.php” to “/templates/your-template/html”
这意味着一旦你搬家router.php
对于您的“本地”,升级后您无需重做所有内容。 (当然,除非 router.php 已更新,以防万一您最好再次镜像它。)
感谢您抽出时间来解决这个难题!
参考
1-更改/删除 URL 中的文章 ID? http://forum.joomla.org/viewtopic.php?t=398429
2- 删除商品 ID 号 http://www.hyde-design.co.uk/joomla-training/joomla-bites/146-removing-the-id-number-from-joomla-25-articles
4-从 joomla 3.0 的 url 中删除文章 ID http://forum.joomla.org/viewtopic.php?t=826165
5-启用 SEF http://docs.joomla.org/Enabling_Search_Engine_Friendly_%28SEF%29_URLs
6-从 joomla 3 URL 中删除文章 ID https://joomla.stackexchange.com/questions/988/remove-article-id-from-joomla-3-url
7-从 joomla 3 URL 中删除文章 ID https://stackoverflow.com/questions/23809575/remove-article-id-from-joomla-3-url
8-.htaccess 重定向规则 https://stackoverflow.com/questions/19877131/htaccess-redirect-rule-for-for-removing-article-id
9-测试.htaccess http://htaccess.madewithlove.be/
已编辑(2016 年 5 月 2 日):Joomla 最新版本 3.5 的新赏金