2017-04-10 49 views
-1

是否有可能檢查Url與正則表達式來驗證?htaccess只發送電子郵件與特殊域

URL看起來:

域中我們的營銷部門可以輸入一個郵箱地址只能用 - > @ domain.com或domain-marketing.com。

(營銷部輸入的URL中的電子郵件地址,將鏈接發送給用戶,他們輸入了數據和發送的形式向*@domain.com或*@domain-marketing.com)

感謝

+0

這可能是我的理解,但我真的不能工作出了問題就在這裏什麼。你能夠編輯你的問題,使其更清楚一點嗎? – DaveyDaveDave

+0

例如:URL - > https://www.domian.com/secure/[email protected]或...... [email protected]我會只有@ domian.com和domain-test-com域在輸入後才起作用。如果它是一個其他域名(... @ gmail.com),我將得到一個禁止訪問。 – nothinghalosix

回答

0

解決這個問題:

$email = $_GET['ID']; // remember to filter this! 
$regex = '#\[email protected](?<domain>\w+\-?\w+\.\w+)#'; 

preg_match($regex, $email, $matches); 
$domain = $matches['domain']; 

if ($domain !== 'example-test.com') { 
    // Unauthorised 
}