RewriteEngine On
RewriteBase /
RewriteRule http://要跳转的域名/$ http://要转向的域名/ [R=301,L]
RewriteRule ^(.*)article/list_([0-9]+).html$ $1/article/list_$2 [R=301,L]
{/tabs-pane}
{tabs-pane label="Web.config"}
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="rule1" stopProcessing="true">
<match url="^news/list_([0-9]+)" />
<action type="Rewrite" url="index.php?m=content&c=index&a=lists&catid=1&page={R:5}" />
</rule>
<rule name="WWW Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^需要转的域名$" />
</conditions>
<action type="Redirect" url="http://要转到的域名/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
{/tabs-pane}
域名解析添加CNAME记录,主机记录www或@,或者您的二级域名,记录值为您的目标网站URL。表现为在浏览器地址栏输入网址,网页加载呈现的是另外一个域名或网页的内容,浏览器地址栏网址不变。
<meta http-equiv="refresh" content="1" url="http://xxx.xxx.com/">
{/tabs-pane}
{tabs-pane label="js跳转"}
<script type="text/javascript">
window.location.href = "http://xxx.xxx.com/";
</script>
{/tabs-pane}
{tabs-pane label="PHP代码跳转"}
<?php
//重定向浏览器
header("Location: https://xxx.xxx.com");
//确保重定向后,后续代码不会被执行
exit;
?>
{/tabs-pane}
server {
listen 80;
server_name xxx.com;
location / {
rewrite ^ https://xxx.xxx.com$request_uri permanent;
}
}
sudo service nginx restart
评语 (1)