形式为
http://localhost/site/page.html?view=about
1.配置config/man.php文件
'urlManager'=>array(
'urlFormat'=>'path',
'urlSuffix'=>'.html',
'showScriptName'=>false, // 这一步是将代码里链接的index.php隐藏掉。
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
2.开启apache mod_rewrite模块
3.在index.php同级模块建立
.htaccess
<IfModule rewrite_module>
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</IfModule>
http://localhost/site/page.html?view=about
1.配置config/man.php文件
'urlManager'=>array(
'urlFormat'=>'path',
'urlSuffix'=>'.html',
'showScriptName'=>false, // 这一步是将代码里链接的index.php隐藏掉。
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
2.开启apache mod_rewrite模块
3.在index.php同级模块建立
.htaccess
<IfModule rewrite_module>
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</IfModule>
本文详细介绍了如何通过配置config/man.php文件、开启Apache mod_rewrite模块以及创建.htaccess文件来优化网站URL管理,并实现简洁的路径式URL结构。
528

被折叠的 条评论
为什么被折叠?



