gpt4 book ai didi

apache - .htaccess 301 从旧域重定向到新域,而页面结构和 url 相同

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:27:00 31 4
gpt4 key购买 nike

我想重定向 http://olddomain.comhttp://newdomain.com对于我所有的 urls..keeping 新域上的页面相同。我的意思是像下面这样的 URL

http://olddomain.com/home/category/page.html
http://olddomain.com/home/mybook/page2.html
http://olddomain.com/login

should be 301 redirect to the new newdomain but same pages, like below

http://newdomain.com/home/category/page.html
http://newdomain.com/home/mybook/page2.html
http://newdomain.com/login

这是我目前在 .htaccess 中的内容

RewriteEngine on
RewriteCond $1 !^(index\.php|img|public|robots\.txt) [NC]
RewriteRule ^(.*)$ /index.php?/$1 [L]

请帮助我干净利落地做这件事,并详细说明痛苦的事情,因为我是新手。

还有人知道搜索引擎可能需要多长时间才能从我的旧域的引用中移走吗?我的意思是搜索查询中的旧域 url 应该被新域 url 替换...n 旧域应该远离搜索引擎。

最佳答案

在.htaccess开头添加如下代码-

    RewriteEngine On

# Redirect Entire Site to New Domain
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^another.olddomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]

关于apache - .htaccess 301 从旧域重定向到新域,而页面结构和 url 相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13001173/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com