简体   繁体   中英

Converting htaccess to Nginx

Hello stackoverflow Users,

i found a nice Tutorial about PHP routing on the Internet. My Problem is that i am using Nginx on my Server. I test some Solutions that i found on the Internet, but nothing works :( For frameworks like Laravel i am using:

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

This is .htaccess from the Tutorial:

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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