标签:
伪静态,通过设置server服务,做域名地址的转换工作。
urlManager地址美化,通过程序的方式实现地址美化工作。
通过在主配置文件里配置组件来实现:
'components'=>array( // uncomment the following to enable URLs in path-format 'urlManager'=>array( 'urlFormat'=>'path', //配置路由 能够起到省略 r= 'rules'=>array( //加入后缀 user/login.html ===> user/login 别人会以为我们有静态页面 'user/login'=>array('user/login','urlSuffix'=>'.html'), //user/register.html ===> user/register 'user/register'=>array('user/register','urlSuffix'=>'.html'), //goods/20 ====> goods/detail&id=20 <>里面试正則表達式。 省略了当中方法,id作为參数 'goods/<id:\d+>' => 'goods/detail', //goods/20/zhangsan ===> goods/category&id=20&name=zhangsan 'goods/<id:\d+>/<name:[a-z]+>'=>'goods/category', //goods/4-2-3-5.html ===> goods/category&brand=4&price2&color=3&screen=5 'goods/<brand:\d+>-<price:\d+>-<color:\d+>-<screen:\d+>'=>array('goods/category','urlSuffix'=>'.html'), ), ),
假设去掉index.php入口文件,通过伪静态来实现
开启apache重写模块服务httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
开启文件夹重写权限
AllowOverride all
3. 设置server级伪静态规则.htaccess文件到站点入口文件夹
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php
标签:
原文地址:http://www.cnblogs.com/mengfanrong/p/5191140.html