【问题标题】:How to redirect without changing link to another link in .htaccess如何在不更改链接的情况下重定向到 .htaccess 中的另一个链接
【发布时间】:2017-07-31 02:44:48
【问题描述】:

我正在尝试通过我的网站访问另一个网站。我使用 .htaccess 重定向代码来做到这一点,但它没有完成。

我想在不更改网址的情况下将https://web.karlosms.com 重定向到http://36.255.3.40:80

我尝试使用此代码,但它不起作用。

RewriteEngine On
RewriteCond %{HTTP_HOST} ^web.karlosms.com
RewriteRule ^(.*) http://36.255.3.40:80/$1 [P]

显示错误:

Forbidden

You don't have permission to access /index.html on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

请帮助我。谢谢。

【问题讨论】:

  • 嗨,我的回答有帮助吗?请提供反馈。

标签: php apache .htaccess redirect


【解决方案1】:

您不能重写到远程服务器。

您需要使用代理指令来实现这一点,这可能并不理想,但这是保留初始 URL 的唯一解决方案。

https://httpd.apache.org/docs/2.4/mod/mod_proxy.html

此外,您需要修复远程服务器上发生的情况(即使重定向时也不应该出现 403),但是为什么不直接将 web.karlosms.com 设置为 36.255.3.40 并定义此远程服务器上的正确虚拟主机?

两者之间似乎没有特定的端口或文件夹映射,因此您可以从最终服务器交付所有内容。中间有一个代理很复杂。

【讨论】:

    猜你喜欢
    • 2012-12-09
    • 1970-01-01
    • 2019-02-16
    • 1970-01-01
    • 1970-01-01
    • 2020-08-23
    • 1970-01-01
    • 1970-01-01
    • 2020-04-23
    相关资源
    最近更新 更多