我想创建一个像这样的网址:http : //domain.com/index.php/hir/2015-02-12/news_title
这是我的urlmanager无法正常工作的地方:
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'hir/<date:\d+>/<title:\w+>'=>'news/view',
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
这是我的.htaccess:
Options +FollowSymLinks
IndexIgnore */*
<IfModule mod_rewrite.c>
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
</IfModule>
RewriteEngine on
无需.htacces文件,您可以通过url-manager解决此问题。只需像这样更改您的第一个url-manager规则:
'hir/<date:\d+>/<title:\w+>'=>'news/view' TO 'hir/<date>/<title>'=>'news/view'
我认为这会对您有所帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句