1. 程式人生 > >wordpress更改“固定連結”模式後,頁面出現404原因及解決方法

wordpress更改“固定連結”模式後,頁面出現404原因及解決方法

Nginx 解決方案:

在 /etc/nginx/config.d/mysit.conf檔案的 loction \ {} 中新增

if (-f $request_filename/index.html){
    rewrite (.*) $1/index.html break;
}

if (-f $request_filename/index.php){
    rewrite (.*) $1/index.php;
}

if (!-f $request_filename){
    rewrite (.*) /index.php;
}

完成後重啟nginx:service nginx restart
Apache解決方案:

etc/httpd/conf/httpd.config 檔案

原因一:Apache中的rewrite模組沒有開啟,去除這一行前面的#號就可以了

LoadModule rewrite_module modules/mod_rewrite.so

原因二:AllowOverride Not Enabled;伺服器可能沒開啟AllowOverride。如果httpd.config的AllowOverride設定的是None,那.htaccess將被忽略。找到以下2處位置並修改:

<Directory />
Options FollowSymLinks
AllowOverride All

</Directory>
<Directory /var/www/html>

… other directives…

AllowOverride All

修改完成後,要重啟Apache才能生效。

service httpd restart