Examples of Nginx rewrite rules in Laravel

Source: Internet
Author: User
This article mainly introduces Laravel's nginx rewrite rule instance code, the need for friends can refer to the following

Laravel Basic Rewrite rules


Location/{    index index.html index.htm index.php;    Try_files $uri $uri//index.php? $query _string; }

Remove the trailing slash, SEO more friendly


if (!-d $request _filename) {   rewrite ^/(. +)/$/$1 permanent;}

Remove Index Action


if ($request _uri ~* index/?$) {     rewrite ^/(. *)/index/?$/$1 Permanent;}

URL rewriting according to laravel rules


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

Error message jump page must be location ~ \.php(.*)${} added to the bar: Fastcgi_intercept_errors on to turn on error detection information

#nginx错误信息跳转自定义页面50x. html to define itself casually


Error_page 404 502 503 504 error.html;location = error.html {    root  html;}

Root is the directory of the error file

Summarize

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.