编辑
事实证明,由于nginx不使用它,所以我试图编辑.htaccess时出错了。我显然需要做的是编辑.conf文件。在我阅读本文之前,my_app.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-data,然后更改永久链接-不起作用。然后,在更改永久链接之前,将其更改为此:
# 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运行家庭服务器。关于这里发生的事情有什么想法吗?