Apache下利用htaccess重定向
站点目录新建.htaccess文件输入如下内容:
<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /#定义默认首页DirectoryIndex index.php index.html index.htm#http跳转httpsRewriteCond %{SERVER_PORT} !^443$RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]#根域名跳转wwwRewriteCond %{http_host} ^baidu.com [NC]RewriteRule ^(.*)$ https://www.fcwys.cc/$1 [L,R=301]#子目录跳转RewriteCond %{HTTP_HOST} ^aaa\.baidu\.com$ [NC]RewriteCond %{REQUEST_URI} !^/aaa/RewriteRule ^(.*)$ cjcx/$1?Rewrite [L,QSA]#自定义404页面RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /404.html [L]</IfModule>#禁止指定文件被查看<FilesMatch (.*)\.(csv|bak|com|sql|cab|jar|dat|z|db)$>Order allow,denydeny from all</FilesMatch>
注:具体地址和目录根据实际情况修改。
