Maison > php教程 > php手册 > le corps du texte

thinkphp在低版本Nginx 下支持PATHINFO的方法分享,nginxpathinfo

WBOY
Libérer: 2016-06-13 08:38:09
original
839 Les gens l'ont consulté

thinkphp在低版本Nginx 下支持PATHINFO的方法分享,nginxpathinfo

最近在用thinkphp做一个项目,基本完成后部署到nginx服务器上才发觉nginx是不支持pathinfo的那么我们如何来处理呢。

Nginx环境

在Nginx低版本中,是不支持PATHINFO的,但是可以通过在Nginx.conf(在/usr/local/nginx/conf/nginx.conf或者通过find / | grep nginx.conf来查找位置)中配置转发规则实现:在nginx配置文件中添加:

location / { 
if (!-e $request_filename) {
   rewrite ^(.*)$ /index.php?s=$1 last;
   break;
 }
} 

Copier après la connexion

其实内部是转发到了ThinkPHP提供的兼容模式的URL,利用这种方式,可以解决其他不支持PATHINFO的WEB服务器环境。
如果你的ThinkPHP安装在二级目录,Nginx的伪静态方法设置如下,其中youdomain是所在的目录名称。

location /youdomain/ {
 if (!-e $request_filename){
  rewrite ^/youdomain/(.*)$ /youdomain/index.php?s=$1 last;
 }
} 
Copier après la connexion

如:

location /thinkphp/ {
 if (!-e $request_filename){
    rewrite ^/thinkphp/(.*)$ /thinkphp/index.php?s=$1 last;
 }
}
Copier après la connexion

语法:rewrite regex replacement flag  (last     相当于apache里面的[L]标记,表示rewrite。)

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Recommandations populaires
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!