Last active
May 17, 2018 17:48
-
-
Save kenzie/5811327 to your computer and use it in GitHub Desktop.
Nginx virtual host configuration for Craft CMS, PHP5-FPM, NGINX 1.2.1 and craft/config/general.php for friendly URLs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
root /var/www/craft.dev/public; | |
index index.php index.html index.htm; | |
server_name craft.dev; | |
location / { | |
try_files $uri $uri/ @rewrites; | |
} | |
location @rewrites { | |
rewrite ^(.*) /index.php?p=$1 last; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
} | |
error_page 404 /index.php; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* General Configuration | |
* | |
* All of your system's general configuration settings go in here. | |
* You can see a list of the default settings in craft/app/etc/config/defaults/general.php | |
*/ | |
return array( | |
/** | |
* Whether generated URLs should be formatted using PATH_INFO, e.g. http://domain.com/index.php/path/, | |
* as opposed to using the query string, e.g. http://domain.com/index.php?p=path | |
* | |
* Possible values: true, false, 'auto' | |
*/ | |
'usePathInfo' => true | |
); |
Prior to this config, I had my craft entries loading properly, but the admin wasn't loading assets from the right directories (css, js, etc.). This nginx config helped me to get it all working properly - thanks!
@keithmancuso I know your comment is years old, but here's a more efficient way to make that config:
location / {
try_files $uri $uri/ @rewrites;
}
location @rewrites {
rewrite ^(/en_gb|de|fr|es)?/(.*)$ $1/index.php?p=$2&$args? last;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've tried everything I can think of on this, but my URLs still come out craft.dev/index.php/pageurl
Am I missing something really obvious?
EDIT:
A small bit of digging discovered the config option of
'omitScriptNameInUrls' => true
makes all the difference.