[英]Wordpress permalinks 404 not found
我想將我的永久鏈接結構修改為 /%postname%/ 以在 wordpress 網站服務器上使用 Buddypress。
經過一些試驗,我遇到了一些麻煩,即使我在不同的論壇中搜索,我也不知道如何解決。
我的 .htaccess 權限用於試用版 666,因此 wordpress 必須修改此文件,但不會(在我的服務器安裝時修改最后一個文件)。 在數據庫中,永久鏈接結構成功傳遞給 %postname%。
現在,我想訪問的所有頁面都出現 404 錯誤。
.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
我運行 Apache,所以為了強制選擇 vars,我在 wp-include/vars.php 中修改了這個:
//$is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false);
$is_apache = 1;
我現在必須做什么?
#編輯:我已經重新安裝了它,重試做所有這些,同樣的問題...... Apache 是文件的所有者,所以我真的不明白......
如果您能夠訪問 wp-admin 面板,那么請嘗試將永久鏈接結構更新為“Plain”,然后檢查您是否仍然收到 404 頁面錯誤。
即使我在使用 apache 服務器的 aws ubuntu 機器上部署我的 wordpress 站點時也遇到了同樣的問題,如果您已將 wordpress 站點部署在 /var/www/html 中,我們必須在 000-default.conf 中添加此行
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
然后我們必須重新啟動 apache 服務器 sudo service apache2 restart
好的,我已經解決了這個問題。
問題,我沒有在我的問題解釋中指定它,是我使用 Virtualhost(我在這個服務器上也有一個監控網站,所以我想分離所有的任務,日志等......),並且有一個問題使用虛擬主機和此指令:
RewriteBase /
事實上,這在正常的 apache 環境中工作,但在虛擬主機中無效。
所以我必須做的是將我的 .htaccess 內容移動到 vhost conf.d 文件中:
<VirtualHost *:80>
ServerAdmin nfrbezar@vdbassocies.fr
ServerName intranet.vdb.local
ServerAlias intranet
DocumentRoot /var/www/vhosts/intranet/html
ErrorLog /var/www/vhosts/intranet/logs/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/www/vhosts/intranet/logs/access.log combined
<Directory "/">
RewriteEngine On
AllowOverride None
Allow from 10.1.1.0/8
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
</Directory>
</VirtualHost>
通過這種方式,它現在可以工作了!
很抱歉沒有告訴你它是一個虛擬主機,我認為這對解決問題並不重要,即使我認為這是一個 apache 問題。
根據wordpress的權限.htaccess應該是604。應用這個權限,檢查一下。
600 -rw------- /home/user/wp-config.php
604 -rw----r-- /home/user/cgi-bin/.htaccess
600 -rw------- /home/user/cgi-bin/php.ini
711 -rwx--x--x /home/user/cgi-bin/php.cgi
100 ---x------ /home/user/cgi-bin/php5.cgi
還要確保具有必要權限的 .htaccess 位於 /var/www/html 中,即使 wordpress 安裝位於不同的文件夾中
就我而言,它是緩存(Redis 用作對象緩存)。 更改永久鏈接設置后,WordPress 使用了新的 URL,但都導致了 HTTP 404 Not Found 錯誤。 wp @production cache flush
緩存(例如使用 WP CLI、 wp @production cache flush
)修復了這個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.