从 URL 中删除 ID(类别和文章) (Joomla 3.3/3.4/3.5)

Get rid of ID (category and article) from URL (Joomla 3.3 / 3.4 / 3.5)(从 URL 中删除 ID(类别和文章) (Joomla 3.3/3.4/3.5))
本文介绍了从 URL 中删除 ID(类别和文章) (Joomla 3.3/3.4/3.5)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Joomla 3.3.6(已3.5.)站点,仅分为 3 个级别:

I have a Joomla 3.3.6 (edited: 3.5.) site organized in only 3 levels:

  • 四大类别(i、ii、iii、iii)
  • 每一个都分为一些中间类别(A、B、C、...)
  • 最后是文章
  • 两种语言(en、pt)

设置Search Engine Friendly URLs使用URL重写添加后缀到URL和<代码>多语言支持,应该的形式是:

The URL after setting Search Engine Friendly URLs, Use URL rewriting, Adds Suffix to URL and multilanguage support, should be in the form:

http://www.example.com/en/bigcatiii/intercatA/articlex.html

但是,自从 Joomla-Baby-Version 以来,许多其他人安装了 Joomla 并要求解决方案,我得到了:

But as many others that have Joomla installed and ask for a solution since Joomla-Baby-Version, I got:

http://www.example.com/en/bigcatiii/666-intercatA/articlex.html

其中 666 是一个来自地狱的数字,它毫无意义地表示类别 ID

where 666 is a number from hell indicating for no purpose a category ID

现在浏览答案,我找到了这个答案:

Now browsing for an answer, I found this answer:

 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行已经和原文一样了.其次,这并不能解决问题.它确实适用于:

Well, first of all, line 426 is already like that in the original. Second, this does not do the trick. It do works with:

http://www.example.com/en/bigcatiii/intercatA/articlex.html

但是,如果您浏览到:

http://www.example.com/en/bigcatiii/intercatA.html

另外,我注意到 ID 号码不同.虽然整个网址是

Also, I noticed that the ID numbers are different. While the whole URL is

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]

URLs 显示正常,但未找到页面.如果我们能提供一个使用 .htaccess 而不是改变 Joomla 核心的解决方案,那就更好了.

The URLs appear ok, but the pages are not found. It would be so much better if we can provide a solution using .htaccess instead of changing Joomla core.

不过,如果这个其他 googled 建议有效,更改 Joomla 核心就可以了.

Still, changing the Joomla core would just fine, if this other googled suggestion was valid.

 Copy "components/com_content/router.php" to "/templates/your-template/html"

这意味着一旦您将 router.php 移动到您的本地",您就无需在升级后重做所有内容.(当然,除非 router.php 更新了,以防你最好再次镜像它.)

Meaning that once you moved router.php to your "local", you wouldn't need to redo all the stuff after an upgrade. (Unless, of course, router.php is updated, in case you would better mirror it again.)

感谢您抽出时间解决这个难题!

Thanks for your time to solve this puzzle!

参考资料

1- 更改/删除 URL 中的文章 ID?

2- 删除文章 ID 号

3- 如何删除 url 中的文章 ID?

4- 从 joomla 3.0 的 url 中删除文章 ID

5- 启用 SEF

6- 从 joomla 中删除文章 ID3 网址

7- 从 joomla 3 URL 中删除文章 ID

8- .htaccess 重定向规则

9- 测试 .htaccess

已编辑 (2016/May/02):Joomla 最新版本 3.5 的新赏金

Edited (2016/May/02): NEW Bounty for Joomla last version 3.5

推荐答案

我刚刚安装了 joomla 3.5,旧方法对我有用.由于路由器文件中的某些内容已被修改,因此您必须在 joomla 升级后重复该过程.

I've just newly installed a joomla 3.5 and the old method works for me. Since something has been modified in the router file, you have to repeat the procedure after a joomla upgrade.

现在 ./components/com_content/router.php 中的行是 34 和 295.

The lines are now 34 and 295 in ./components/com_content/router.php.

再次将 0 更改为 1 使其变为:

Again change the 0 into 1 so that it becomes:

$advanced = $params->get('sef_advanced_link', 1);


我的网址是例如http://joomla.lan/en/category-en-gb/article-en-gb使用 Search Engine Friendly URLs 可以正常工作.


My URL is e.g. http://joomla.lan/en/category-en-gb/article-en-gb works fine with Search Engine Friendly URLs on.

随着 Adds Suffix to URL 切换为 Yes,一个 .html 被附加到 URL.
Use URL RewritingUnicode Aliases 可选工作.在 IIS7 或 Apache 上使用 URL 重写引擎时,您必须将 htaccess.txt 重命名为 .htaccess 并将 webconfig.txt 重命名为 webconfig.请注意,某些托管商具有限制性的服务器配置.如果您收到 500 内部服务器错误,您可能需要编辑 .htaccess 并注释掉 Options +FollowSymlinks 和/或 Options -Indexes 和/或 RewriteBase/ 通过添加前面的 #.后者已在 Joomla 3.5 中停用.RewriteBase 设置在 Joomla 安装在子文件夹而不是 Web 根目录中时很有用.

With Adds Suffix to URL switched to Yes an .html is appended to the URL.
Use URL Rewriting and Unicode Aliases work optionally. When using URL rewrite engine on IIS7 or Apache, you have to rename htaccess.txt into .htaccess and webconfig.txt into webconfig. Note that some hosters have a restrictive server configuration. If you get a 500 internal server error, you might need to edit .htaccess and comment out the lines Options +FollowSymlinks and/or Options -Indexes and/or RewriteBase / by adding a preceding #. The latter is already deactivated in Joomla 3.5. A RewriteBase setting is useful when Joomla is installed in a subfolder, not the web root.

在其他服务器上将Use URL Rewriting设置为No.

On other servers set Use URL Rewriting to No.

我无法重现您的问题,这两个代码编辑后一切正常.请再试一次,如果您无法解决,请发布确切的行为(网址、错误等).如果无法修复,则可能需要重新安装源.

I can't reproduce your problem, everything is working correct with those two code edits. Please try it out again and if you can't resolve, post the exact behavior (urls, errors aso.) If you can not get it fixed, you might have to reinstall the sources.

这篇关于从 URL 中删除 ID(类别和文章) (Joomla 3.3/3.4/3.5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)