你好想用 htaccess 重定向所有以 .html 结尾的 URL 到像这样的子域
到
在新站点上,我安装了 WordPress,我想处理所有 HTTP 请求,因为旧站点没有使用 HTTPS 广告,避免冲突 WP
提前致谢
这实际上取决于您使用的 Web 服务器。 2 个流行的 Web 服务器是 Apache 和 Nginx。
如果您使用的是 Apache,您可以在根目录中创建
.htaccess
文件,内容如下:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*)\.html$ http://archive.example.com/$1.html [R=301,L]
如果您使用的是 Nginx,则需要更新配置文件以包含以下内容:
server {
listen 80;
server_name example.com;
rewrite ^/(.*)\.html$ http://archive.example.com/$1.html permanent;
}
如您所见,我们在 Apache 中使用 301 重定向,在 Nginx 中使用
permanent
,因为它们是最终的。
您还需要为 archive.example.com 子域设置 DNS 记录