Rewrite .htaccess on nginx

Francis Daly francis at daoine.org
Tue Sep 1 22:36:05 UTC 2020


On Tue, Sep 01, 2020 at 03:34:33PM -0400, Jorge Enrique Diaz wrote:

Hi there,

> i want to do this in nginx
> 
> Options All -Indexes
> RewriteEngine on
> 
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteCond %{REQUEST_FILENAME} !-f 
> RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] 

That is approximately "try_files $uri $uri/ /index.php?url=$uri;", which
would appear inside a location{}; and there would also be (probably)
something involving fastcgi_pass for handling the "php" requests.

http://nginx.org/r/try_files for the try_files documentation, and similar
urls for any other directives used.

> http {

> 	location / {

http://nginx.org/r/location

"location" cannot be directly inside "http"; it must be inside "server".

> NGINX EMERG LOCATION IS NOT ALLOWED HERE IN
> C.\LARAGON\BIN\NGINX\NGINX1.14.0/CONF/NGINX.CONF:37

That is reporting that "location" cannot be directly inside "http".

Probably the simplest is to start with whatever initial config file
your system has, and see what "location" block inside a "server" block
is used to handle a test request. Then adjust that "location", or add
a new one beside it, for your testing.

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list