I am trying to activate pretty permalinks on my wordpress installation, but no success. I’m changing this file /etc/nginx/conf.d/default.conf
I tried the following:
server{
if (!-e $request_filename) { rewrite ^.*$ /index.php last;
server {
if ($host ~* ^myhost.com$) {
rewrite ^(.*) http://www.myhost.com$1 permanent;
break;
}
location / {
try_files $uri $uri/ /index.php?q=$request_uri;
}
But none of these worked :(. Here is my full file:
server {
listen 80;
server_name example.com;
return 301 http://www.example.com$request_uri;
}
server {
listen 80;
server_name www.example.com;
note that these lines are originally from the "location /" block
root /usr/share/nginx/html;
index index.php index.html index.htm;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Can you help me please?
Thanks a lot.
Don’t forget to restart your
nginx
server after updatingdefault.conf
file (sudo /etc/init.d/nginx restart
)It is a bit late,
try