Rewrite .htaccess on nginx

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Rewrite .htaccess on nginx

zakirenish
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]


when converting it as it appears in several forums it gives me this script

user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;








events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request"
'
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;
       
        autoindex off;

        autoindex off;

        location / {
                if (!-e $request_filename){
                rewrite ^(.*)$ index.php?url=$1 break;
                }
        }
       
       

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
       
    include "C:/laragon/etc/nginx/php_upstream.conf";
    include "C:/laragon/etc/nginx/sites-enabled/*.conf";
    client_max_body_size 2000M;
        server_names_hash_bucket_size 64;
       
       
       

       
}
 

DOES NOT START NGIX AND I GET THE FOLLOWING ERROR

SERVICE NGINX CANNOT START RASON :

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

HELPPPP ME PLEASE

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,289276,289276#msg-289276

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Rewrite .htaccess on nginx

Francis Daly
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        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx