.htaccess 将所有页面重定向到新域

编程入门 行业动态 更新时间:2024-10-26 10:39:31
本文介绍了.htaccess 将所有页面重定向到新域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我将使用哪个重定向规则将 olddomain.example 下的所有页面重定向到 newdomain.example?

Which redirect rule would I use to redirect all pages under olddomain.example to be redirected to newdomain.example?

该站点的结构完全不同,因此我希望旧域下的每个页面都重定向到新域索引页面.

The site has a totally different structure, so I want every page under the old domain to be redirected to the new domain index page.

我认为这样做(在 olddomain.example 基目录下):

I thought this would do (under olddomain.example base directory):

RewriteEngine On RewriteRule ^(.*)$ newdomain.example/ [R=301]

但是如果我导航到 olddomain.example/somepage,我会被重定向到 newdomain.example/somepage.我期望只重定向到 newdomain.example 而没有页面后缀.

But if I navigate to olddomain.example/somepage I get redirected to newdomain.example/somepage. I am expecting a redirect only to newdomain.example without the page suffix.

如何保留最后一部分?

推荐答案

可能是这样的:

Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^OLDDOMAIN$ [NC] RewriteRule ^(.*)$ NEWDOMAIN [R=301,L]

更多推荐

.htaccess 将所有页面重定向到新域

本文发布于:2023-10-31 16:42:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546671.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:到新   重定向   页面   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!