Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx rewriting rule instance code of Laravel

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Laravel basic rewriting rules

Location / {index index.html index.htm index.php; try_files $uri $uri/ / index.php?$query_string;}

Without the slash at the end, SEO is 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 add a bar in location ~\ .php (. *) ${}: fastcgi_intercept_errors on enables error detection message

# nginx error message Jump Custom Page 50x.html define it yourself

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

Root is the root directory of the error file

Summary

The above is the example code of Laravel Nginx rewriting rules introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply you in time. Thank you very much for your support to the website!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report