关于thinkphp的url重写,其核心点基本上都是去掉url路径中的index.php,其余的内容和普通的伪静态没有什么区别了。
我想要的结果无非是去掉url路径中的index.php
首先是配置.htaccess
<ifmodule mod_rewrite.c>rewriteengine onrewritecond %{request_filename} !-drewritecond %{request_filename} !-frewriterule ^(.*)$ index.php/$1 [qsa,pt,l]</ifmodule>
因为我部署在apache上面,需要httpd.conf配置文件中找到loadmodule rewrite_module modules/mod_rewrite.so去掉前面的#,找到allowoverride none改为allowoverride all。
现在访问localhost/product有效,但是__app__或者__url__或者u获取出来的路径包含有index.php,也就是为localhost/index.php,原来还有一步,需要在conf/config.php里面修改或者添加'url_model'=>2,
而因为我尝试部署的是基于thinkphp的conist企业版2.0,在config.php里竟然有这么一个配置'url_model' =>c('token.false_static'),,而token.false_static的值在初始化的时候被设置为了1,所以。。。模式一直还是1,pathinfo模式。
在新浪sae部署,不支持.htaccess,只支持其自有的配置文件config.yaml,所以要在config.yaml添加下面这段重写格式代码:
handle:- rewrite: if(!is_dir() && !is_file() && path~"^(.*)$") goto "index.php/$1"
以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注!
相关推荐:
thinkphp5.0框架访问url的方法
以上就是对thinkphp的url重写的分析的详细内容。