Преобразование .htaccess в NGINX блок - PullRequest
0 голосов
/ 19 января 2020

Итак, вот текущий блок Сервера. Я хочу, чтобы он получал доступ к файлам, как если бы .php был добавлен без отображения расширения .php в строке URL.

server {
    root /var/www/ucp;

    index index.html index.htm index.nginx-debian.html index.php;

    server_name fc-rp.net;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }


    # pass PHP scripts to FastCGI server
    #
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny all;
    }

    location /phpmyadmin {
           root /var/www/phpmyadmin;
           index index.php index.html index.htm;
           location ~ ^/phpmyadmin/(.+\.php)$ {
                   try_files $uri =404;
                   root /var/www/phpmyadmin;
                   fastcgi_pass unix:/run/php/php7.2-fpm.sock;
                   fastcgi_index index.php;
                   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                   include /etc/nginx/fastcgi_params;
           }
           location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                   root /var/www/phpmyadmin;
           }
    }


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/fc-rp.net/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/fc-rp.net/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
    if ($host = fc-rp.net) {
        return 301 https://$host$request_uri;
    } # managed by Certbot



    server_name fc-rp.net;
    listen 80;
    return 404; # managed by Certbot


}

Предоставлено .htaccess ..

<IfModule mod_rewrite.c>
        RewriteEngine On

        #       If you are having problems with the rewrite rules, remove the "#" from the
        #       line that begins "RewriteBase" below. You will also have to change the path
        #       of the rewrite to reflect the path to your XenForo installation.
        #RewriteBase /xenforo

        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
</IfModule>
...