Nginx under the Laravel in the site Directory of the two-level directory URL rewrite method

Source: Internet
Author: User
Tags php framework
I'm using the Nginx1.9.9,laravel 5.1.11 version.
Project many people will feel, localhost under a pile of folders a pile of items, each time a new project is accustomed to directly under the site root directory, after all, in the local development debugging, how convenient how to come.
So I have a lot of things in localhost, http://localhost/asd/, or http://localhost/caugoo/similar to many, but now a lot of PHP framework to a route, configure a URL rewrite, Under Apache is very convenient, but under the nginx will be a few more.
Take my new project as an example, the project requires Laravel to do, so I threw the whole project into a folder called Laravel, the directory becomes C:/nginx/html/laravel, and then found only through localhost/laravel/ Public to access, after all, Laravel's entry file index.php in public.
Find a Find Laravel root directory server.php can also achieve this effect, the server.php renamed to Index.php, and then in Nginx that configuration file plus the following code, the successful URL rewrite to this index.php ...

Similarly, the configuration of other frameworks under Nginx is similar, such as thinkphp, and do not need to change what server.php file, because thinkphp these framework root directory is index.php.

location/laravel/{            index  index.html index.htm index.php;            if (!-e $request _filename) {                rewrite  ^/laravel/(. *) $  /laravel/index.php?s=$1 last  ;            }        }

The above describes the Nginx Laravel in the site Directory of the two-level directory URL rewrite method, including the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.