繁体   English   中英

将htaccess转换为Nginx

[英]Converting htaccess to Nginx

Hello stackoverflow用户,

我发现了一个很好的关于互联网上PHP路由的教程。 我的问题是我在我的服务器上使用Nginx。 我测试了一些我在互联网上找到的解决方案,但没有任何作用:(对于我使用的Laravel这样的框架:

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

这是教程中的.htaccess:

DirectoryIndex index.php

RewriteEngine on

RewriteBase /MYBASEPATH

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

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

这应该工作:

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