更新到4.8后,固定链接将不起作用(全部为404)

时间:2017-07-04 作者:Jadeye

我真的希望能到这里
我尝试了书中的所有工具
Save changespermalinks 第页
我已安装debug this 看看发生了什么query...
我重复了其他操作和配置更改,但没有任何效果
我花了好几个小时阅读.htaccess 参数以及nginx 服务器块配置。。。没什么不好的
我的menu 继续给予404 除非我设置permalinksplain.
我在linode VPS, ubuntu 14.04 + LEMP 这是我的.htaccess &;我的站点的配置。。。

.htaccess

# 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

<Files 403.shtml>
order allow,deny
allow from all
</Files>

# Leverage Browser Caching Ninja -- Starts here
<IfModule mod_expires.c>
ExpiresActive On 
ExpiresDefault "access plus 1 month" 
ExpiresByType image/x-icon "access plus 1 year" 
ExpiresByType image/gif "access plus 1 month" 
ExpiresByType image/png "access plus 1 month" 
ExpiresByType image/jpg "access plus 1 month" 
ExpiresByType image/jpeg "access plus 1 month" 
ExpiresByType text/css "access 1 month" 
ExpiresByType application/javascript "access plus 1 year" 
</IfModule> 
# Leverage Browser Caching Ninja -- Ends here


# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

nginx server block

server {
        server_name www.xxx.com xxx.com;
        root /home/alma/xxx.com;
        index index.php;
        include global/restrictions.conf;
        include global/wordpress_xxx.conf;
        error_log /var/log/nginx/xxx_error.log;
        access_log /var/log/nginx/xxx_access.log;
}

global/wordpress_xxx.conf

# http://wiki.nginx.org/HttpCoreModule
location / {
    #try_files $uri $uri/ /index.php?$args;
    try_files $uri $uri/ /index.php?q=$uri&$args;
}

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

# Directives to send expires headers and turn off 404 error logging.
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;
}

# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ [^/]\\.php(/|$) {
    fastcgi_split_path_info ^(.+?\\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
        return 404;
    }
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#   fastcgi_intercept_errors on;
    fastcgi_param PHP_VALUE "upload_max_filesize = 16M \\n post_max_size=18M";
    client_max_body_size 68M;
    include fastcgi_params;
}

location ~ ^/(wp-admin|wp-login\\.php) {
        auth_basic "Welcome - Admin Restricted Content";
        auth_basic_user_file /etc/nginx/.htpasswd;
}

location = /wp-login.php {
    deny all;

    try_files $uri =404;
    fastcgi_split_path_info ^(.+\\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    include fastcgi_params;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PHP_VALUE "upload_max_filesize = 16M \\n post_max_size=18M";
    client_max_body_size 68M;
}

global/restrictions.conf

# Global restrictions configuration file.
location = /favicon.ico {
    log_not_found off;
    access_log off;
}

location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}

location ~ /\\. {
    deny all;
}

location ~* /(?:uploads|files)/.*\\.php$ {
    deny all;
}
这些都是在最后一次update...
有人遇到过这样的问题吗?有人知道如何解决这个问题吗?我的配置中是否有可能导致update 到4.8
Thanx

P、 错误日志没有显示任何特别的。。。

2 个回复
SO网友:cody cortez

我以前在将一些网站转移到另一台服务器时遇到过这样的问题。

这就是我所做的。编辑您的apache2.conf/etc/apache2/ 文件夹

运行以下命令:

nano /etc/apache2/apache2.conf
向下滚动并查找带有注释的此部分:

# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
确保这是其中的一个:

<Directory /var/www/>
  Options Indexes FollowSymLinks
  AllowOverride all
  Require all granted
</Directory>
简而言之,承认它。让你的永久链接不会失败。

-戴夫

SO网友:Mandu

你可以试试flush_rewrite_rules( $hard );不过,请确保在下载后删除该功能。

https://codex.wordpress.org/Function_Reference/flush_rewrite_rules

结束

相关推荐

Permalinks - Archives

WordPress文档说:WordPress offers you the ability to create a custom URL structure for your permalinks and archives. https://codex.wordpress.org/Settings_Permalinks_Screen 我看到此屏幕将如何为特定帖子/页面创建永久链接,但我没有看到此设置屏幕上关于如何为存档帖子/页面创建链接的任何其他详细信息。有人能澄清一下吗?