0

I have an existing Expressionengine MSM site that I've moved to nginx on my local machine, consisting of 2 sites in subdirectories:

/en
    /system
    /index.php
    /admin.php
/de
    /index.php
    /admin.php
/themes

Sites are accessed through https://mydomain.test/en and https://mydomain.test/de

I can view pages using 'index.php' : https://mydomain.test/en/index.php?/pagename

But I can't seem to get the site working without 'index.php?', my nginx.conf is included below (https://www.nginx.com/resources/wiki/start/topics/recipes/expressionengine/)

user username staff;
worker_processes auto;

events {
    worker_connections  1024;
}

worker_rlimit_nofile 1024;

http {
    include mime.types;
    default_type  application/octet-stream;

    sendfile on;
    keepalive_timeout  65;
    client_max_body_size 128M;

    gzip  on;
    gzip_comp_level 5;
    gzip_min_length 256;
    gzip_proxied any;
    gzip_vary on;

    gzip_types
    application/atom+xml
    application/javascript
    application/json
    application/rss+xml
    application/vnd.ms-fontobject
    application/x-font-ttf
    application/x-web-app-manifest+json
    application/xhtml+xml
    application/xml
    font/opentype
    image/svg+xml
    image/x-icon
    text/css
    text/plain
    text/x-component;

    include /Users/username/.valet/Nginx/*;
    include servers/*;
    include valet/valet.conf;

    server {
        listen 80;
        server_name mydomain;
        root /Users/username/nginx/mydomain/;
        index index.php;

        access_log /usr/local/var/log/nginx/access.log;
        error_log  /usr/local/var/log/nginx/error.log info;

        location /en {
           try_files /en/$uri /en/$uri/ /en/index.php?$query_string;
           disable_symlinks off;
        }

        location /de {
           try_files /de/$uri /de/$uri/ /de/index.php?$query_string;
           disable_symlinks off;
        }

        location @ee {
            rewrite ^(.*) /index.php$1 last;
        }

        location ~ \.php$ {
            include fastcgi_params;
            fastcgi_pass unix:/tmp/php-fastcgi.socket;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME 
            $document_root$fastcgi_script_name;
        }

        # This location is for our EE index.php gateway
        location /index.php {
            include /usr/local/etc/nginx/fastcgi_params;
            set $script     $uri;
            set $path_info  $uri;
            # this will set the path_info when it exists as query string: /index.php?/something/here
            if ($args ~* "^(/.+)$") {
                set $path_info  $1;
            }
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME 
            $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $path_info;
        }
    }

}
0

Please try using RewriteRule ^(.*)$ /index.php?/$1 [L] to remove index.php? from website URL for Apache.

You can also try below code for Ngnix.

if ($request_uri ~* "^(.*/)index\.(html?|php)\/?(.*)$") { return 301 $1$3; }

  • I'm using nginx not Apache. – greebstreebling Apr 16 '18 at 8:08
  • this doesn't seem to work, where should I put it, within a location directive or not? – greebstreebling Apr 17 '18 at 7:22
  • You should put in location directive. – Harsh Barach Apr 17 '18 at 9:12
  • Nope, not working – greebstreebling Apr 19 '18 at 15:12
  • Ah! it was an issue with the gmaps plugin not working with the version of php! Thank you for your help. – greebstreebling Apr 19 '18 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.