Pretty URLs with nginx dont work :(

Hello everyone,

I have ConcreteCms (version 9) running on an nginx server. I would like to activate the Pretty URLs and am not getting anywhere. I can find a bunch of tips for Apache online. I can do it well there too. But now I don’t know what to do with nginx.

Is there anyone here who knows anything about this?

When I activate the Pretty URLs checkbox in the admin interface, I get the message that I should add the following line to the nginx-config in my location-section:

try_files $uri $uri/ /cms/index.php

(btw: my cms is installed in a subdir: /cms)

Unfortunately, this does not work. It can’t! If my URL is

https://mydomain.com/cms/login

Then with this try_files it will never become a

https://mydomain.com/cms/index.php/login

but

https://mydomain.com/cms/index.php

Right?

If tried with some like this:

set $path $request_uri;
if ($request_uri ~ ^/cms/(.*)) {
  set $path $1;
}
try_files $uri $uri/ /cms/index.php/$path /cms/index.php/$path/;

But this wont work, too.

How should this line read correctly?

Does anyone have an idea how I can get PrettyURLs to work?

Thanks for your help

So, after endless fiddling, researching and reading, I have found the solution. If anyone has the same problem with nginx and pretty urls, here is my solution:

in an nginx.conf-file:

location / {
 : 
 try_files $uri $uri/ @rewrite;
 :
}

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

Ergo: The note in the admin interface

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

is probably not correct.

1 Like