1

I am trying to configure NGINX to serve a craft 2 site. I am getting the requests being routed through index.php for template url's but not for any admin routes which are redirecting to index.php?p=/admin/**/*.

I am assuming this has more to do with my NGINX config than craft as I have the following option enabled:

'omitScriptNameInUrls' => 'true',

Is there any craft related reason that admin URL's would redirect that way whereas template url's wouldn't?

here is my nginx config:

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

index index.html index.htm index.php;

server_name _;

error_log  off;
access_log off;

root /code/public;

charset utf-8;


location / {
    try_files $uri/index.html $uri $uri/ /index.php?$query_string;
}

location ~ [^/]\.php(/|$) {
    try_files $uri $uri/ /index.php?$query_string;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass php:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    include fastcgi_params;
}

# Disable reading of Apache .htaccess files
location ~ /\.ht {
    deny all;
}

# Misc settings
sendfile off;
client_max_body_size 100m;

# 404 error handler
error_page 404 /index.php?$query_string;
}

Update:

just deployed this same app to AWS elastic beanstalk and am running into the same issue with Apache. This leads me to think maybe it's not related to nginx?

1

Try adding specific location for admin & cpresources in the nginx config

location ^~ /admin {
    try_files $uri $uri/ /index.php?$query_string;
}
location ^~ /cpresources {
    try_files $uri $uri/ /index.php?$query_string;
}

before

location ~ [^/]\.php(/|$) {
|improve this answer|||||

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.