[英]403 error on wordpress install on subdirectory
我有一個具有以下結構的網站:
/public_html
/main site content (html content mostly)
/.htaccess (1)
/secret (dir)
/wp (dir)
/a wordpress install
/.htaccess (2)
/ secret / wp /是要移至wordpress解決方案的開發站點。 這是我在新網站上工作的地方。
當我嘗試查看新站點時,根.htaccess導致403禁止錯誤。 我知道這是因為從服務器刪除它可以解決此問題。
問題是,它正在為我重寫一些重要的文件擴展名,否則我的主站點將中斷。
htaccess(1)
<Files ~ "^\.(htaccess|htpasswd)$">
deny from all
</Files>
DirectoryIndex index.html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(wp-admin)($|/) - [L] # You don't want to mess with WordPress
RewriteRule ^/secret/wp/ - [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule .* $0.html
# browser requests html
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.html
RewriteRule ^/?(.*)\.html$ /$1 [L,R=301]
# check to see if the request is for a html file:
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^/?(.*)$ /$1.html [L]
</IfModule>
Redirect 301 /shop.html https://mydomain.myshopify.com/
添加行“ RewriteRule ^ / secret / wp /-[L]”是尋找此問題的解決方案的結果,但似乎沒有任何作用。
我的其他.htaccess似乎根本沒有觸發。 為了清楚起見,我將其發布:
.htaccess(2)
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /secret/wp/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /secret/wp/index.php [L]
# Fix 403 errors on existing directories; WordPress overrides.
RewriteCond %{REQUEST_URI} ^/secret/wp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
我不知所措。 我不能只是刪除.htaccess文件,否則整個站點都將中斷,但是我似乎無法弄清楚如何停止403錯誤。 我很確定這是由於重寫規則所致,但似乎並沒有像預期的那樣停止該目錄。
任何幫助將不勝感激。
我認為您可以將其嘗試到您的.htaccess文件中
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
找到了答案。 我花了一周的時間在所有可能的論壇上進行挖掘和測試,但是最終(刪除整個wp安裝並重新安裝到一個干凈的目錄之后),我找到了解決所有問題的最簡單答案:
我必須編輯.htaccess文件以允許“ index.php”作為有效的默認索引頁面。
我的域頂層的.htaccess文件只有以下一行:DirectoryIndex index.html
我只需要將其更改為DirectoryIndex index.html index.php
然后一切正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.