使用 Joomla SEF 重写自定义 url
我正在尝试在 Joomla! 内部重写一些 url! 1.7 已打开 SEF 功能,但似乎无法弄清楚:
存在以下 SEF URL(菜单项):
website.com/local/amsterdam
我想要的是以下内容:
http://website.com/local/amsterdam/trends (不存在) 渲染 http://website.com/local/amsterdam?show=trends 同时仍显示第一个 URL。
使用 .htaccess 可以进行以下工作(但不显示 SEF URL):
RewriteRule ^local/amsterdam/trends$ index.php?option=com_content&view=article&id=14&Itemid=176&show=trends [L]
但这不是:
RewriteRule ^local/amsterdam/trends$ local/amsterdam?show=trends [L]
我希望找到一个无需使用 id 的解决方案,以便它能够动态呈现所有城市的正确页面。我很感激在 .htaccess 中执行此操作的任何想法以及实现此目的的任何不同解决方案!提前致谢。
I'm trying to wrap my head around rewriting some urls internally in Joomla! 1.7 with SEF features turned on but can't seem to figure it out:
The following SEF URL exists (menu item):
website.com/local/amsterdam
What I would like is the following:
http://website.com/local/amsterdam/trends (non-existant)
to render
http://website.com/local/amsterdam?show=trends
while still displaying the first URL.
Working with .htaccess the following works (but doesn't show SEF URL):
RewriteRule ^local/amsterdam/trends$ index.php?option=com_content&view=article&id=14&Itemid=176&show=trends [L]
But this doesn't:
RewriteRule ^local/amsterdam/trends$ local/amsterdam?show=trends [L]
I'm hoping to find a solution without having to use an id so that it will dynamically render the correct page for all cities. I'ld appreciate any thoughts on doing this in .htaccess as well as any different solutions to achieve this! Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然我最初是在寻找 mod-rewrite 解决方案,但我已经找到了一种通过修改(核心)Joomla! 来实现相同目标的方法!路由器。
在 include/router.php 的第 47 行之后:
我添加了以下内容:
现在加载 http:// www.website.com/local/amsterdam/trends,此 URL 在页面 http://www.website.com/local/amsterdam 实际上加载了 ?show=trends 参数。
对我来说,即使修改了核心文件,这也是比使用 mod-rewrite 更灵活的解决方案。您可能想要使用一些条件语句来仅在某些条件下运行此代码。希望有帮助。
Although I was initially searching for a mod-rewrite solution I have figured out a way to achieve the same by modifying the (core) Joomla! router.
On line 47 of includes/router.php after:
I added the following:
Now when loading http://www.website.com/local/amsterdam/trends, this URL is displayed while the page http://www.website.com/local/amsterdam is actually loaded with the ?show=trends parameter.
For me this a more flexible solution than using mod-rewrite even though a core file is modified. You might want to use some conditional statements to only run this code in certain conditions. Hope it helps.