当前位置:首页 > 芯闻号 > 充电吧
[导读]1.给页面添加.html后缀(伪静态),有利于搜索引擎优化源地址: http://localhost/cms/index.php?r=goods/category美化后 http://localhos

1.给页面添加.html后缀(伪静态),有利于搜索引擎优化


源地址: http://localhost/cms/index.php?r=goods/category

美化后 http://localhost/cms/index.php/goods/category.html


方法

2.美化GET传值方式

源地址:http://localhost/cms/index.php?r=goods/detail&id=8

美化后:http://localhost/cms/index.php/goods/8.html


方法


 'goods/'=>array('goods/detail','urlSuffix'=>'.html'),


3:不显示index.php


这个需要到服务器配置,和php没有关系

涉及到apache的重写


首先卡其 rewrite 模块 并重启服务器



2.新建文本文件,写入

RewriteEngine on


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d


RewriteRule . index.php


然后 另存为到网站的根目录下,命名为 .htaccess  

在windows下是创建以 点 开头的文件的,只有另存为方式可以


之后访问

源地址:http://localhost/cms/index.php/goods/8.html

美化后:http://localhost/cms/goods/20.html

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除( 邮箱:macysun@21ic.com )。
换一批
延伸阅读
关闭