簡體   English   中英

如何僅在請求來自特定域時才允許htaccess執行

[英]How to allow htaccess to perform only if the request is from the particular domain

我有多個域托管帳戶,因此我們都必須知道可以通過主域訪問其他域,如我在前面的問題中所述

根據答案,我在子文件夾中與子域和其他htaccess相關的問題很少

所以我只是想知道如果請求來自特定域,例如example.com,是否可以執行htaccess查詢?

例如 :

if request is from example.com then
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
else
    RewriteCond %{HTTPS} off
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
end if

這樣的事情。 以上陳述僅是示例。

我搜索了此內容,但沒有找到想要的結果。 任何幫助將不勝感激。

您可以檢查引薦來源網址,但請注意,此信息不是很可靠,因為它由訪問者提供並且可以操縱:

RewriteEngine On

RewriteCond %{HTTPS} off
# Add the referrer as a condition for this rewrite rule
RewriteCond %{HTTP_REFERER} example\.com [NC]
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM