htaccess的重定向所有页面的新域名

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

这重定向规则,我会用它来重定向在 olddomain 所有页面重定向到 newdomain ?

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

该网站有一个完全不同的结构,所以我想每一页下的旧域名重定向到新域的索引页

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根目录下):

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

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

但是,如果我浏览到 olddomain/somepage 我重定向到 newdomain/somepage 。我期待一个重定向仅 newdomain 而不在网页后缀。

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

我如何保持的最后一部分了呢?

How do I keep the last part out?

推荐答案

可能是这样,没有测试

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

更多推荐

htaccess的重定向所有页面的新域名

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

发布评论

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

>www.elefans.com

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