最近被各种跳转,烦了,整理下
先说最简单的nginx
比如说你的域名为www.maplem.com maplem.com做301跳转到www.maplem.com
核心代码
server_name www.maplem.com maplem.com;
if ($host != ‘www.maplem.com’) {
rewrite ^/(.*)$ http://www.maplem.com/$1 permanent;
}
然后是apche
<ifmodule mod_rewrite.c>
RewriteEngine on
RewriteRule /([\d\D]*)/([\d\D]*)/(\w+)_for_(\w+).htm /$1/$2/$4.jsp?no=$3 [PT]
RewriteRule /([\d\D]*)/(\w+)_for_(\w+).htm /$1/$3.jsp?no=$2 [PT]
RewriteCond %{HTTP_HOST} ^maplem.com [NC]
RewriteRule ^(.*)$ http://www.maplem.com$1 [L,R=301]
</ifmodule>
然后是iis,其实IIS最简单,但是比较麻烦,就是把maplem.com作为一个新域名在iis中新增一个,文件路径随便,然后选择为重定向到url,输入到http://www.maplem.com即可
过几天把apache和nginx配置的也写下
时间:2012-08-16 22:14:10
Latest posts by Zhiming Zhang (see all)
- aws eks node 自动化扩展工具 Karpenter - 8月 10, 2022
- ReplicationController and ReplicaSet in Kubernetes - 12月 20, 2021
- public key fingerprint - 5月 27, 2021