轉址 .htaccess 文件寫法參寫

舉例要將 A DNS (sample.com)轉址到 B DNS (newsample.com)

RewriteEngine on
RewriteCond %{HTTP_HOST} ^sample\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.sample\.com$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ “https\:\/\/newsample\.com\/” [R=301,L]

 

若 root內的資料夾 htaccess寫錯,即便設定 reDirect 301 也會造成404- Not Found轉址失效