Maison > développement back-end > tutoriel php > nginx目录权限控制

nginx目录权限控制

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Libérer: 2016-06-13 11:11:15
original
1069 Les gens l'ont consulté

nginx目录权限控制求助

1

<br />server {<br />    listen       80;<br />    server_name  admin.my.com;<br /><br />  location / {<br />        root   D:/www/webroot;<br />      index  index.php;<br />   }<br /><br />        error_page 404 = http://admin.my.com/error.html;<br /><br />   location ~ \.php$ {<br />     root        D:/www/webroot;<br />     fastcgi_pass    127.0.0.1:9000;<br />     fastcgi_index   index.php;<br />      fastcgi_param   SCRIPT_FILENAME  D:/www/webroot$fastcgi_script_name;<br />        include     fastcgi_params;<br /> }<br />}<br />

Copier après la connexion


fastcgi.conf如上配置

我这个系统的url结构(非伪静态,只是在入口文件中作了转换):如:
http://admin.my.com/index.php/Index/image

1

 

Copier après la connexion
_code
http://admin.my.com/index.php/Admin/edit_config
http://admin.my.com/index.php/News/add
……
index.php是入口文件,单一入口

但是问题来了,当我访问http://admin.my.com/index.php/Index/image_code的时候
事实上文件路径指向了:D:/www/webroot/index.php/Index/image_code/index.php
因为上面的location中配置了:index index.php; 大概url中的后缀名不是php或者html或者其他“物理存在”的文件,都会自动加上index.php吧,是么????????????

我的目的就是:无论index.php后面有多少个斜杠构成的url,入口文件只能是前面的index.php,而不是把后面的参数认成目录并自动加上index.php。

我知道这个url结构很不规则,但目前改起来比较费事,时间关系,所以在想有没有办法通过nginx配置来解决。求大神,求大仙,谢谢。

感觉还是apache好用,一下子就搞定了:

1

<br /><VirtualHost *:80><br />    ServerAdmin [email&#160;protected]<br />    DocumentRoot /<br />    ServerName admin.my.com<br />    Alias /  "D:/www/webroot/"<br />    <Directory "D:/www/webroot/"><br />    Options  FollowSymLinks MultiViews ExecCGI<br />   <br />   Order allow,deny<br />       Allow from all <br />    </Directory><br />   ErrorLog logs/admin-error.log<br />   #CustomLog logs/admin-access.log common<br /></VirtualHost><br />

Copier après la connexion

nginx apache server
------解决方案--------------------
location ~ \.php$
去掉php后的 $  正则中$意味着结束。去掉也就告诉了nginx把所有.php*文件交给fpm处理,而不只是.php。
然后将执行文件名改为index.php
fastcgi_param    SCRIPT_FILENAME  D:/www/webroot/index.php;
剩下的就看你的应用了。

这个算是比较简单的配置,要想了解更完善的方法,自己去搜吧,这方面的说明真太多了
Étiquettes associées:
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
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal