简体   繁体   English

将htaccess转换为Nginx

[英]Converting htaccess to Nginx

Hello stackoverflow Users, Hello stackoverflow用户,

i found a nice Tutorial about PHP routing on the Internet. 我发现了一个很好的关于互联网上PHP路由的教程。 My Problem is that i am using Nginx on my Server. 我的问题是我在我的服务器上使用Nginx。 I test some Solutions that i found on the Internet, but nothing works :( For frameworks like Laravel i am using: 我测试了一些我在互联网上找到的解决方案,但没有任何作用:(对于我使用的Laravel这样的框架:

location / {
  try_files $uri $uri/ /index.php?$query_string;
}

This is .htaccess from the Tutorial: 这是教程中的.htaccess:

DirectoryIndex index.php

RewriteEngine on

RewriteBase /MYBASEPATH

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php [QSA]

This should work: 这应该工作:

location / {
    try_files $uri $uri/ /index.php?$query_string;

    rewrite ^/(.*)$ /index.php/$1;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM