I have nginx running with php 7 fpm. My Wordpress permalinks are setup with /%postname%/
. assuming my domain is example.com
I want to have permalinks like that: example.com/postname/
But this leads to an error. I can find the post with this link: example.com/index.php?postname/
How do I get rid of the index.php?
in the links?
My Nginx config
server {
server_name localhost;
root /var/www/;
index index.html index.htm index.php;
location ~\.php$ {
try_files $uri =404;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param REQUEST_URI $args;
}
location / {
try_files $uri $uri/ /index.php$args;
}
location /wordpress/ {
try_files $uri $uri/ /wordpress/index.php?$args;
}
}
You question implies that WordPress is installed at location /
, so I am not sure why you have a location /wordpress
also.
There are some issues with your configuration.
The value for REQUEST_URI should be set to $request_uri
which is probably already the default value in the fastcgi_params
file. This is the parameter that index.php
uses to decode the pretty permalink.
Delete the line fastcgi_param REQUEST_URI $args;
.
Your try_files
statement is missing a ?
. Use either:
try_files $uri $uri/ /index.php?$args;
Or:
try_files $uri $uri/ /index.php;
I have found that passing $args
to /index.php
is not necessary with WordPress.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.