Problem with redirect to subfolder Error 404 Index.php not found

Discussion in 'Installation/Configuration' started by snicker, May 10, 2018.

  1. snicker

    snicker New Member

    Hello Community,
    I use the following configurations The Perfect Server - Debian 9 (Nginx, BIND, Dovecot, ISPConfig 3.1)
    Debian and Nginx is working fine with the default settings.
    The index.html with the NGINX default path (/var/www/clients/client1/web1) is also working.
    Now i have the Problem to change the path of the index.html to another directory (/var/www/clients/client1/web1/subfolder) with ISPConfig.
    When I redirect with "permanent" there is an 404 error not found
    How can I modify the vhost to make the index.php run?
    Please can anybody help me? I am digging around since days, also I found nothing in the manual, which is understanable for newbies ;)

    Thank you for your efforts (I am a beginner)
    snicker

    vhost.conf
    Code:
    server {
            listen IP4:80;
    
            listen Ip4:443 ssl http2;
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
            ssl_certificate /var/www/clients/client1/web1/ssl/mydomain-le.crt;
            ssl_certificate_key /var/www/clients/client1/web1/ssl/mydomain-le.key;
    
            server_name mydomain ;
    
            root   /var/www/mydomain/web/;
    
            if ($http_host = "www.mydomain-path.de") {
                rewrite ^ $scheme://mydomain$request_uri? permanent;
            }
            if ($scheme != "https") {
                rewrite ^ https://$http_host$request_uri? permanent;
            }
    
            rewrite ^(?!/(subfolder|stats|error|\.well-known/acme-challenge))/(.*)$ /subfolder/$2 permanent;
            index index.html index.htm index.php index.cgi index.pl index.xhtml;
    
    
    
            error_page 400 /error/400.html;
            error_page 401 /error/401.html;
            error_page 403 /error/403.html;
            error_page 404 /error/404.html;
            error_page 405 /error/405.html;
            error_page 500 /error/500.html;
            error_page 502 /error/502.html;
            error_page 503 /error/503.html;
            recursive_error_pages on;
            location = /error/400.html {
    
                internal;
            }
            location = /error/401.html {
    
                internal;
            }
            location = /error/403.html {
    
                internal;
            }
            location = /error/404.html {
    
                internal;
            }
            location = /error/405.html {
    
                internal;
            }
            location = /error/500.html {
    
                internal;
            }
            location = /error/502.html {
    
                internal;
            }
            location = /error/503.html {
    
                internal;
            }
    
            error_log /var/log/ispconfig/httpd/mydomain-path.de/error.log;
            access_log /var/log/ispconfig/httpd/mydomain-path.de/access.log combined;
    
            location ~ /\. {
                deny all;
            }
    
            location ^~ /.well-known/acme-challenge/ {
                access_log off;
                log_not_found off;
                root /usr/local/ispconfig/interface/acme/;
                autoindex off;
                index index.html;
                try_files $uri $uri/ =404;
            }
    
            location = /favicon.ico {
                log_not_found off;
                access_log off;
                expires max;
                add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            }
    
            location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
            }
    
            location /stats/ {
    
                index index.html index.php;
                auth_basic "Members Only";
                auth_basic_user_file /var/www/clients/client1/web1/web/stats/.htpasswd_stats;
            }
    
            location ^~ /awstats-icon {
                alias /usr/share/awstats/icon;
            }
    
            location ~ \.php$ {
                try_files /69ac73998d9ca71910a6a11fefc4ce52.htm @php;
            }
    
            location @php {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass unix:/var/lib/php7.0-fpm/web1.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
            }
    
    
    
    
            location / {
                index index.php;
                try_files $uri $uri/ /index.php?$query_string;
            }
    
            location /public/ {
                sendfile                                    on;
                tcp_nopush                              on;
                tcp_nodelay                              on;
                keepalive_timeout                   10s;
                sendfile_max_chunk              512k;
            }
    
    
    
    }
     
    Last edited: May 20, 2018

Share This Page