添加自定义.htaccess后,Joomla菜单分配无法正常工作

时间:2014-05-29 07:03:29

标签: php .htaccess joomla

我创建了一个组件'com_listings',用户可以在其中添加他们的单位。

目前网址是(工作得非常好):

http://example.com/index.php?option=com_listings&view=space&layout=details&id=32

将规则添加到.htaccess

RewriteRule ^listings/([0-9]+)$ index.php?option=com_listings&view=space&layout=details&id=$1 [NC,L]

新的清洁网址

http://example.com/listings/14

在新的Url中显示所有模块,这些模块显示在主页上,请指导我在哪里做错了。

感谢。

1 个答案:

答案 0 :(得分:1)

你没有在Joomla中使用.htaccess来创建SEF URL,默认.htaccess已经为Joomla设置了能够将请求路由到正确的组件的东西,你的额外规则可能正在破坏这一点。

Joomla组件有router.php file that is called to generate the SEF URL,您可以在Joomla Doc's网站上阅读。

当您在PHP中生成链接时,您会通过JRoute::_()传递原始网址(例如您的第一个网址)。

e.g。

$ url = JRoute :: _('index.php?option = com_listings& view = space& layout = details& id = 32');

这会将SEF样式的网址放入$url