【问题标题】:How to redirect localhost/dir to localhost?如何将 localhost/dir 重定向到 localhost?
【发布时间】:2014-08-16 04:36:07
【问题描述】:

我正在测试我的 Android 应用,我想检查我系统中的所有层。我的 macbook 上有服务器,我想将所有请求从我的 Android 设备重定向到 macbook。我在 Android 上安装了主机并更改了主机文件。 mac 上的服务器正在本地主机上工作。与设备和电脑连接正常。但我的应用程序发送请求,如“localhost/dir/request”。 如果我不想更改设备中的 localhost/dir/request,而只想将所有请求(如 localhost/dir/request 类型)重定向到我的 Mac 上的 localhost/request,我需要做什么? 如何将所有 localhost/dir/request 重定向到 localhost/request?

【问题讨论】:

  • 您必须首先将localhost/dir/request 转换为macip/requestServer on mac is working on localhost?没有没用的。该服务器应该在 mac 的 LAN 地址上工作。我称之为macip。
  • 是的,现在我在配置中使用 macip/request URL 编译 apk 以进行测试。但我想从生产服务器获取 .apk,安装到我的测试设备并在不更改代码的情况下对其进行测试。
  • 只需添加共享首选项,用户可以在其中选择/编辑主机和目录。为什么要大惊小怪?你想要的从一个有根设备开始,如果一切都可能我不知道。你想测试什么,因为我不明白你对 I want to check all layers in my system 的意思?

标签: android macos redirect localhost


【解决方案1】:

您可以使用 Web 根文件夹中的 .htaccess 文件。看看这个website about the .htaccess file

您的文件将如下所示:

RewriteEngine On
RewriteRule ^(.*)/request$ http://example.com/request [L]

【讨论】:

    猜你喜欢
    • 2013-09-14
    • 1970-01-01
    • 2022-11-29
    • 2012-08-27
    • 2016-01-21
    • 2020-12-28
    • 2018-10-02
    • 2013-10-10
    • 2018-01-21
    相关资源
    最近更新 更多