無法瀏覽到apache伺服器上的子網域,取得禁止的資源權限

無法瀏覽到apache伺服器上的子網域,取得禁止的資源權限

我有 cPanelA 和網站 A...以及子網域 A1 - 一切正常。

我已經使用網站 B 建立了一個新的 cPanelB...並且需要將子網域 A1 作為子網域 B1 移至 cPanel B。

網站 B 正在運作...但是將所有子網域 A1 複製到 cPanel B 後,我無法讓子網域 B1 運作。它不斷返回Forbidden - you don't have permission to access this resource

在 cPanelB 中,我已驗證所有檔案/目錄擁有權是否正確。我驗證了所有檔案權限是否正確(檔案權限為 0644,目錄權限為 0755)。我驗證了新 cPanel 已啟用 PHP(透過 WHM)。經過一個多小時的挫敗之後,我驗證了子網域 B1 檔案結構/權限/所有權與子網域 A1 上的檔案結構/權限/所有權相同。

我將 .htaccess 檔案從網站 A 和子網域 A1 複製到網站 B 和子網域 B - 然後將所有網域參考變更為新的 B 子/網域。所以我不認為它是我的 .htaccess 檔案...它們實際上似乎在工作,因為根/www/.htaccess檔案重寫了指向子網域資料夾/www/club,我可以在瀏覽器中看到它實際上使其進入子網域B 。

我知道這可能會是一件乏味的事情,但我對問題可能是什麼一無所知。

www/.htaccess:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^api\. [NC]
RewriteRule !^api/ api%{REQUEST_URI} [L,NC]  // api.domainB.com
RewriteCond %{HTTP_HOST} ^portal\. [NC]      // portal.domainB.com
RewriteRule !^club/ portal%{REQUEST_URI} [L,NC]

Options -Indexes

SetEnvIf X-Rquested-With com.domainB domainB

#AddType application/x-httpd-php7 .html .htm

ErrorDocument 404 https://www.domainB.com/errorpage.html

# file upload info

DirectoryIndex index.html index.htm index.php
AddHandler application/x-httpd-ea-php73 .php .html .htm .phtml

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

www/club/.htaccess 用於:portal.domainB.com

RewriteEngine On

RewriteCond %{HTTP_HOST} !^portal\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteRule ^ -  [F]

#AddType application/x-httpd-php5 .html .htm

DirectoryIndex index.html index.htm index.php

Header set Access-Control-Allow-Origin "*"
AddHandler application/x-httpd-ea-php73 .php .html .php7 .phtml
ErrorDocument 404 https://portal.domainB.com/errorpage.html

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php73 .php .php7 .phtml .html
</IfModule>
# php -- END cPanel-generated handler, do not edit

答案1

好吧,我想通了。今天早上醒來,有預感,結果發現這就是問題所在。

RewriteRule ^ -  [F]

該行強制發生403 Forbidden錯誤。我將相同的 .htaccess 檔案套用至 api.domainA.com 並將其複製到 api.domainB.com,這也是正確的。但也將 api.domainB.com .htaccess 檔案複製到 Portal.domainB.com,並且該子網域需要使用者登錄,但[F]阻止了登錄頁面的出現。

相關內容