gpt4 book ai didi

apache - .htaccess 精确 url 重定向

转载 作者:行者123 更新时间:2023-12-04 06:17:50 26 4
gpt4 key购买 nike

我有两个网站:
example.com
yyy.com

他们都有类似的网络应用程序,但在不同的服务器上。我想让 Apache 将所有路径请求重定向到 example.com 完全相同的方式yyy.com .

例如:

1. Request:     example.com/pages/contacts
Redirects to yyy.com/pages/contacts
2. Request: example.com/search?first_val=45&second_val=45
Redirects to yyy.com/search?first_val=45&second_val=45

那么,有什么方法可以制作这样的 .htaccess文件?如果是,我该怎么做?

最佳答案

尝试这样的事情:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com$ [OR]
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ http://www.yyy.com/$1 [R=301,L]

关于apache - .htaccess 精确 url 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7015001/

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