亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何為這個問題編寫 htaccess 文件?

如何為這個問題編寫 htaccess 文件?

PHP
HUH函數 2023-04-02 10:33:58
我有 CPanel,主要網站存儲在 Main-Site 文件夾中,這是我當前的 .htaccess 文件。RewriteEngine onRewriteCond %{HTTP_HOST} ^example.com$ [NC,OR]RewriteCond %{HTTP_HOST} ^www.example.com$RewriteCond %{REQUEST_URI} !Main-Site/RewriteRule (.*) /Main-Site/$1 [L]RewriteEngine OnRewriteCond %{HTTP_HOST} example\.com [NC]RewriteCond %{SERVER_PORT} 80RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]ErrorDocument 206  /errors/206.htmlErrorDocument 301  /errors/301.htmlErrorDocument 302  /errors/302.htmlErrorDocument 400  /errors/400.htmlErrorDocument 401  /errors/401.htmlErrorDocument 403  /errors/403.htmlErrorDocument 404  /errors/404.htmlErrorDocument 408  /errors/408.htmlErrorDocument 500  /errors/500.htmlErrorDocument 501  /errors/501.htmlErrorDocument 503  /errors/503.html但是這個 .htaccess 文件正在影響子域,例如docs.example.com就像我嘗試訪問子域時轉到 404.html 如何解決這個問題?我也被迫重定向 https
查看完整描述

1 回答

?
largeQ

TA貢獻2039條經驗 獲得超8個贊

剛剛找到問題的解決方案


RewriteEngine on 

RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 

RewriteCond %{REQUEST_URI} !^/Main-Site/ 

RewriteCond %{REQUEST_FILENAME} !-f 

RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^(.*)$ /Main-Site/$1  

RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 

RewriteRule ^(/)?$ Main-Site/ [L]


Options +SymLinksIfOwnerMatch



RewriteEngine On


# Apply these rules BEFORE rules in child .htaccess files

RewriteOptions InheritDownBefore


# HTTP to HTTPS redirect for all subdomains

RewriteCond %{HTTPS} !=on [NC]

RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]




ErrorDocument 206  /errors/206.html

ErrorDocument 301  /errors/301.html

ErrorDocument 302  /errors/302.html

ErrorDocument 400  /errors/400.html

ErrorDocument 401  /errors/401.html

ErrorDocument 403  /errors/403.html

ErrorDocument 404  /errors/404.html

ErrorDocument 408  /errors/408.html

ErrorDocument 500  /errors/500.html

ErrorDocument 501  /errors/501.html

ErrorDocument 503  /errors/503.html


查看完整回答
反對 回復 2023-04-02
  • 1 回答
  • 0 關注
  • 114 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號