0

我有以下結構的網站:403錯誤上安裝WordPress的子目錄

/public_html 
    /main site content (html content mostly) 
    /.htaccess (1) 
    /secret (dir) 
     /wp (dir) 
      /a wordpress install 
      /.htaccess (2) 

/祕密/ 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/ 

添加行 「重寫規則^ /祕密/ 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錯誤。我很確定這是因爲重寫規則,但它似乎並沒有停止像它應該的目錄。

任何幫助將不勝感激。

回答

0

找到了答案此。花了挖掘,並通過一切可能的論壇上,我能找到的測試,但最終(刪除整個WP安裝並重新安裝到一個乾淨的目錄後)的一個星期,我發現,固定這一切的最簡單的答案:

我必須編輯我的.htaccess文件以允許「index.php」作爲有效的 默認索引頁面。

我的域的頂層我的.htaccess文件只有這一行: 的DirectoryIndex index.html的

我不得不改變它的DirectoryIndex index.html的index.php文件

然後一切工作。

0

我想你可以嘗試到你的.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] 
+0

你能解釋一下它應該去的地方嗎?或者它將試圖完成什麼?我嘗試了幾個地方,但它不會改變我嘗試訪問mydomain.com/secret/wp/ –

+0

時得到的403錯誤,它將搜索子目錄wp-content,wp-admin和wp-includes 。 –

+0

請確保你的服務器上有mod_rewrite –