• nginx下如何l在网站目录的二级目录下url重写的方法


    以我新项目为例子,该项目要求用laravel来做,因此我把整个项目丢到一个叫laravel的文件夹里面了,目录就变成c:/nginx/html/laravel了,然后发现只能通过localhost/laravel/public来访问,毕竟laravel的入口文件index.php在public里面。

    在nginx下配置其他框架也差不多如此,比如thinkphp,而且还不需要改什么server.php文件,因为thinkphp这些框架根目录就是index.php了。

    location /laravel/ {  

           index  index.html index.htm index.php;  

      if (!-e $request_filename){  

                    rewrite  ^/laravel/(.*)$  /laravel/index.php?s=$1  last;  

            }  

    }  

    1、项目在根目录:

            location / {
                index  index.html index.htm index.php l.php;
                autoindex  on;

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

    2、项目在二级目录: localhost/YII/basic/web

        location /YII/basic/web/ {  
                   index  index.html index.htm index.php l.php;
                   autoindex  on;
                if (!-e $request_filename){    
                    rewrite  ^/YII/basic/web/(.*)$  /YII/basic/web/index.php?s=$1  last;    
                }
            }

  • 相关阅读:
    参考__JAVA
    债券价格和通胀率
    C++ 面试题
    欧式和美式期权
    explicit
    smart pointer
    const pointer
    manacher-马拉车算法
    输入有空格的字符串的2种方法
    bind()与connect()——计网中socket的使用
  • 原文地址:https://www.cnblogs.com/feixiablog/p/8885960.html
Copyright © 2020-2023  润新知