user2490493
user2490493

Reputation: 1

htaccess to nginx (help)

I am trying to convert the code from the htaccess to Nginx but without any success, and yes i have tried all the online converter but it did not help, so can any here on stockoverflow help me please? I'm going crazy soon :-p (Here is the code from the htaccess)

RewriteCond %{HTTP_HOST} ^www.WEBSITE.com
RewriteRule (.*) http://WEBSITE.com/$1 [R=301,L]
RewriteCond %{request_filename} -f
RewriteRule ^(.*) $1 [L]
RewriteRule ^([a-z]+)(/([^/]{0,32})(/.+)?)?$  index.php?a=$1&q=$3    [L]

Upvotes: 0

Views: 97

Answers (1)

Fleshgrinder
Fleshgrinder

Reputation: 16273

Please try the following:

server {
    listen 80;
    server_name www.website.com;
    return 301 $scheme://website.com;
}

server {
    listen 80;
    server_name website.com;
    root /path/to/root;

    location / {
        try_files $uri @rewrite;
    }

    location @rewrite {
        rewrite ^/([a-z]+)/?([0-9a-zA-Z]*)/?.*$ /index.php?a=$1&q=$2 last;
    }
}

Upvotes: 1

Related Questions