因爲我網站是架設在Linux的VPS上的,因此我用例以下方法html
.htaccess文件
首先要開啓Apache服務器的.htaccess功能,我在Apache安全配置中有分享過;開啓以後新建一個.htaccess文件放在網站根目錄下,文件內容爲python
<Files ~ "^\.(htaccess|htpasswd)$"> deny from all </Files> RewriteEngine on RewriteCond %{HTTP_HOST} ^(evilxr\.com)(:80)? [NC] RewriteRule ^(.*) http://www.evilxr.com/$1 [R=301,L] order deny,allow
最後一步重啓服務器安全
service httpd restart