使用 htaccess 重定向网站

redirect website using htaccess

我有一个网站:

http://site1.com

和第二个网站:

http://89.89.89.89:8888

当我访问 http://site1.com/site2/ to show the content of http://89.89.89.89:8888 时我想要那个。 我也希望 URL 保持不变。前任: 而不是 http://89.89.89.89:8888/Page1.htm i want the URL to be http://site1.com/site2/Page1.htm 。 此外,当我从 Page1.htm 导航到 Page2.htm 时,URL 将是 http://site1.com/site2/Page2.htm

谢谢。

你需要 proxypass 才能做那样的事情。您需要确保在 apache 中加载了 mod_proxy。然后在规则中使用 P 标志。你可以这样试试。

RewriteCond %{REQUEST_URI} ^/site2 [NC]
RewriteRule ^(.*)/?$ http://89.89.89.89:8888/ [L,P]

要启用 mod_proxy,您通常只需要在 apache 配置和 reload/restart apache 中取消注释这些行。

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so