Need to remove index.php from URI

Discussion in 'ISPConfig 3 Priority Support' started by mircsicz, Dec 18, 2017.

  1. mircsicz

    mircsicz New Member

    I'm trying to rewrite URL's from a ISPConfig 3 NGinX installation. It's hosting a Contao installation we just changed the URL scheme

    So I need mydom.com/index.php/Startpage.html to become mydom.com/Startpage.html

    I've added:
    Code:
    # Remove index.php$
    if ($request_uri ~* "^(.*/)index\.php$") {
            return 301 $1;
        }
    
    location \ {
            try_files $uri $uri/ /index.php?$query_string;
       
            # Remove from everywhere index.php
            if ($request_uri ~* "^(.*/)index\.php(/?)(.*)") {
                return 301 $1$3;
            }
        }
    
    # Remove trailing slash.
    if (!-d $request_filename) {
        rewrite ^/(.+)/$ /$1 permanent;
    }
    
    # Clean Double Slashes
    if ($request_uri ~* "\/\/") {
      rewrite ^/(.*) /$1 permanent;
    }
    
    And also add a config File with some Contao specific optimization's:
    Code:
    client_max_body_size 200M;
    
    
    
    # Anpassungen für Contao
        location / {
            try_files $uri $uri/ /index.php?$args;
    #                auth_basic "Devs Only";
    #                auth_basic_user_file /var/customers/www/clients/client1/web13/web/.htpasswd;
                }
    
        location ~* \.(tpl|html5|xhtml)$ {
            deny all;
        }
    
        location ~ /\. {
            deny all;
            access_log off;
            log_not_found off;
        }
    
        location ~* (/scripts|/system/logs|/system/bin|/system/config) {
            deny all;
        }
    
        location ~* .(gif|jpg|jpeg|png|ico|wmv|3gp|avi|mpg|mpeg|mp4|flv|mp3|mid|js|css|wml|swf)$ {
            #root   /var/www/vhosts/DOMAINNAME/html;
            expires max;
            add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        }
    
    # Anpassungen für Contao Ende
    
    # der direkte Aufruf von Dateien wird in Verzeichnissen mit .ht(access), .ht(dumm) o. .ht(however) einfach mal gesperrt
        location ~ /\.ht {
                deny all;
        }
    But I can't get it to work
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Did you try to use just this 'basic' rewrite rule set?

    Code:
    location ~* \.(tpl|html5|xhtml)$ {
    deny all;
    }
    location / {
    try_files $uri $uri/ /index.php?$args;
    }
    location ~* \.(jpg|jpeg|png|gif|css|js|ico)$ {
    expires max;
    log_not_found off;
    }
    
    This calls index.php for all incoming 'virtual' URL's so contao should be able to handle the content delivery then.
     

Share This Page