编辑
结果是我试图编辑的树弄错了。htaccess,因为nginx不使用它。我显然需要做的是编辑我的。conf文件。在我读这篇文章之前,我的\\u应用程序。conf如下所示:
upstream backend {
server unix:/u/apps/my_app/tmp/php.sock;
}
server {
listen 80 default;
root /u/apps/my_app/www;
index index.php;
access_log /u/apps/my_app/logs/access.log;
error_log /u/apps/my_app/logs/error.log;
location / {
try_files $uri $uri/ /index.php;
}
# This location block matches anything ending in .php and sends it to
# our PHP-FPM socket, defined in the upstream block above.
location ~ \\.php$ {
try_files $uri =404;
fastcgi_pass backend;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /u/apps/my_app/www$fastcgi_script_name;
include fastcgi_params;
}
# This location block is used to view PHP-FPM stats
location ~ ^/(php_status|php_ping)$ {
fastcgi_pass backend;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
include fastcgi_params;
allow 127.0.0.1;
deny all;
}
# This location block is used to view nginx stats
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
现在看起来是这样的,但仍然不起作用:
upstream backend {
server unix:/u/apps/my_app/tmp/php.sock;
}
server {
listen 80 default;
root /u/apps/my_app/www;
index index.php;
access_log /u/apps/my_app/logs/access.log;
error_log /u/apps/my_app/logs/error.log;
location / {
try_files $uri $uri/ /index.php;
}
location /wordpress/ {
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~* ^.+\\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2 |doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}
# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-wp-super-cache.conf;
#include global/wordpress-w3-total-cache.conf;
# This location block matches anything ending in .php and sends it to
# our PHP-FPM socket, defined in the upstream block above.
location ~ \\.php$ {
try_files $uri =404;
fastcgi_pass backend;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /u/apps/my_app/www$fastcgi_script_name;
include fastcgi_params;
}
# This location block is used to view PHP-FPM stats
location ~ ^/(php_status|php_ping)$ {
fastcgi_pass backend;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
include fastcgi_params;
allow 127.0.0.1;
deny all;
}
# This location block is used to view nginx stats
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
有人知道我做错了什么吗?
结束编辑,我已将永久链接从默认更改为/%postname%/,现在WordPress管理面板中的链接给了我404个错误,而不是WordPress 404页面,nginx 404页面。查找为什么这是告诉我,这应该是编辑我的。htaccess文件或告诉我WordPress无法重写。htaccess-的。htaccess文件不存在,当我更改永久链接时,WordPress没有给出任何错误。
我试过创建一个空白。我的wordpress文件夹中的htaccess文件,给它666个权限,将用户和组更改为www数据,然后更改永久链接-这不起作用。然后,在更改永久链接之前,我将其更改为:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
当那不起作用时,我改变了
RewriteBase
到
/wordpress/
在再次更改永久链接之前-仍然没有什么。
我也进入了我的网站。conf文件并已更改try_files $uri $uri/ /index.php;
对于以下各项,每次重新启动nginx和php5 fpm;
try_files $uri $uri/ /index.php?$query_string;
try_files $uri $uri/ /index.php?q=$request_uri;
try_files $uri $uri/ /index.php?$args;
我正在用nginx运行一个家庭服务器。你知道这是怎么回事吗?
SO网友:Domi
我正在使用wordpress multisite和自定义永久链接设置:/%category%/%postname%/
/etc/nginx/site available/domain。形态
在服务器上{
location / {
try_files $uri $uri/ /index.php?q=$uri$args;
}
如果您的根wordpress不是webroot,而是
http://domain.com/wordpress/:
location /wordpress/ {
try_files $uri $uri/ /wordpress/index.php?q=$uri$args;
}
如果您在博客中使用旧的wordpress。目录,添加:位置^ ~/博客。dir{内部;别名/var/www/wordpress/wp-content/blogs.dir;access\\u-log-off;log\\u-not\\u-found-off;expires-max;}
检查nginx配置:sudo nginx-t
重新加载nginx:sudo服务nginx Reload
还可以尝试更改永久链接设置。