Redirect all request to homepage on Ispconfig with nginx

Discussion in 'General' started by lnxgs, Oct 16, 2015.

  1. lnxgs

    lnxgs Member

    Hi,
    I installed last version of ispconfig on Debian Jessie with nginx.
    I set up a website that had a forum. The forum has been removed. I would like to redirect every forum/* request to home page.

    This nginx directive should be enough:

    location ~ ^/forum(.*)$ {
    return 301 /;
    }

    However, if I put ask for http://www.example.com/forum/what-ever.php or anything with *.php, it does not work and it returns a nginx error.
    Basically I get the point that *.php is processed before the nginx directive I put on the ispconfig web domain option field.
    If I put the code before "location ~ \.php", it works.

    Code:
    server {
            listen *:80;
            server_name example.com www.example.com;
            root   /var/www/example.com/web;
            index index.html index.htm index.php index.cgi index.pl index.xhtml;
            error_log /var/log/ispconfig/httpd/example.com/error.log;
            access_log /var/log/ispconfig/httpd/example.com/access.log combined;
            location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
            }
            location = /favicon.ico {
                log_not_found off;
                access_log off;
            }
            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/web20/web/stats/.htpasswd_stats;
            }
            location ^~ /awstats-icon {
                alias /usr/share/awstats/icon;
            }
            location ~ ^/forum(.*)$ {
                return 301 /;
            }
    location ~ \.php$ {
                try_files /3431268c40be0cf8a556c509aafec15c.htm @php;
            }
            location @php {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass unix:/var/lib/php5-fpm/web20.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
            }
    
    Is it possible to put my directive in this position using ispconfig and not editing manually the example.com.vhost file?

    Regards,
    L.
     
  2. lnxgs

    lnxgs Member

    Hi,
    no idea?

    Regards,
    L.
     

Share This Page