wordpress設置“固定鏈接”后,頁面404錯誤的解決方法


Nginx 解決方案:

網上盛傳的方法是:

在 /etc/nginx/nginx.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; }
復制代碼

特別注意:這種設置方法小編測試是無效的,會導致網站排版亂碼。

正確的設置方式是loction / {}中添加配置:

復制代碼
#加入如下一條命令即可
try_files $uri $uri/ /index.php?$args;
復制代碼

修改完成后重啟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 </Directory>

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

service httpd restart


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM