0
我試圖路由所有段,但也有例外。 所以我想要路線:任何除(home | about | contact)。類似的東西。Zend路由器與正則表達式
我已經設法在codeigniter中做到這一點,但我在Zend Framework中遇到了一些困難。 CI中我會寫這行我CONFIGS/routes.php文件文件:
$route['^(?!home|about|contact)\S*'] = "category";
這是我在我的routes.xml我的Zend項目。
<category>
<type>Zend_Controller_Router_Route_Regex</type>
<route>(?!home|about|contact)</route>
<defaults>
<controller>category</controller>
<action>index</action>
</defaults>
<reverse>%s</reverse>
</category>
如果你嘗試一些非常簡單的事情會發生什麼?簡單的'家'成功地匹配「家」?然後嘗試「home | about」,並逐步建立您的正則表達式來識別問題。 –
我解決了我的問題。在我的路由定義中,我需要包含我在codeigniter ^(?! home | about | contact)\ S *中使用的整個正則表達式。所以我會有(^(?!首頁|關於|聯繫人)\ S *) 和所有的網址不包含家庭或關於或聯繫將會去我的類別控制器。不管怎麼說,還是要謝謝你。 –
WingLeung