2012-02-03 108 views
0

在Joomla 1.7上,Joomla允許在別名中使用逗號。爲了安全起見,URL中帶有逗號的頁面上的Mod_security 404s。在沒有別名的情況下獲取Joomla中的鏈接?

Gavick News Show Pro是在主頁上列出最新消息的模塊。它創建到內部頁面的鏈接包括使用逗號的別名,我們需要將其刪除。

在Gavick代碼它得到的鏈接是這樣的:

$link = ($news_id !== 0) ? JRoute::_(ContentHelperRoute::getArticleRoute($news_id, $news_cid)) : JRoute::_('index.php?option=com_user&view=login');

其產生的鏈接,例如:

http://example.com/index.php?option=com_content&view=article&id=655:test,ting-here&catid=22:112th-news&Itemid=130

要注意,SEF是不是在這個網站啓用並且不能出於安全原因。希望而不是討論我們特定的安全要求,有人可以幫助解決我們的問題。

是否有另一種方法來獲得除JRoute之外的$ link,將不會在標題中包含這些別名?示例代碼會很好。謝謝!

注意:爲了簡化,這個代碼總是做同樣的事情:

$link = JRoute::_(ContentHelperRoute::getArticleRoute($news_id, $news_cid));

回答

0

如果不使用SEF你不需要通過JROUTE。 JRoute的全部內容是SEF網址。

您更改代碼:

//Non SEF link 
$ns_menuItemId = JSite::getMenu()->getActive(); 
$ns_link = "/index.php?option=com_content&view=article&id=$news_id&catid=$news_cid&itemid=$nbs_menuItemId"; 
$link = ($news_id !== 0) ? $ns_link : JRoute::_('index.php?option=com_user&view=login'); 
+0

對不起不起作用。他們仍然通過您的版本。 – cchiera 2012-02-04 03:26:18

+0

你能給我更多關於它的工作原理嗎?我使用這個URL在我的1.7 dev安裝中追蹤了這一點: 'http://j16ref.site/index.php?option=com_content&view = article&id = 1&catid = 1'並且通過修正,沒有任何別名被拉上。 – Craig 2012-02-04 10:45:12

+0

確定你想要什麼細節?當你使用你的代碼並點擊模塊生成的鏈接時,我會在標題中隨機添加一個字符,我會得到以下URL:index.php?option = com_content&view = article&id = 657:te'〜 - $ -^-_- {} - , - st&catid = 22:112th-news&itemid =文章和類別別名仍然出現。 – cchiera 2012-02-04 15:50:53

相關問題