Heim  >  Artikel  >  Backend-Entwicklung  >  浅谈ThinkPHP的URL重写,浅谈thinkphpurl_PHP教程

浅谈ThinkPHP的URL重写,浅谈thinkphpurl_PHP教程

WBOY
WBOYOriginal
2016-07-13 10:13:13871Durchsuche

浅谈ThinkPHP的URL重写,浅谈thinkphpurl

我想要的结果无非是去掉URL路径中的index.php

首先是配置.htaccess

复制代码 代码如下:


RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

因为我部署在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"

是不是超级简单呢,如果还想深入的学习其他伪静态方面的知识,请好好研读下下面的文章推荐吧。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/917034.htmlTechArticle浅谈ThinkPHP的URL重写,浅谈thinkphpurl 我想要的结果无非是去掉URL路径中的index.php 首先是配置.htaccess 复制代码 代码如下: IfModule mod_rewrite.c...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn