I'm performing a migration from an Apache server to Nginx and missed a .htaccess
file that performs a rewrite:
RewriteRule ^(.*)$ routes.php?params=$1 [NC,QSA]
For example, this endpoint example.com/api/v1/param1/param2/param3
would be rewritten as https://example.com/api/v1/routes.php?params=/param1/param2/param3
Can someone confirm that this is the correct equivalent for Nginx before I re-attempt the migration?
rewrite "(?i)^(.*)$" routes.php?params=$1
and is this how it would be used in the config file since /api/v1
is the only path that requires the rewrite?
location /api/v1 {
rewrite "(?i)^(.*)$" routes.php?params=$1
}
UPDATE
Adding this to the conf file in Laravel Forge appears to just break the application and prevents displaying any views. Instead, it says This site can’t be reached example.com refused to connect.
All
nginx
URIs begin with a leading/
, and your regular expressions do not attempt to remove the/api/v1/
prefix before appending the parameter list.Try: