简体   繁体   English

我无法在Android设备上访问localhost域

[英]I can not access a localhost domain on Android device

I want to test a site that I am developing in my localhost environment on my Android device. 我想测试我在Android设备上的本地主机环境中开发的站点。 I did set up my Android and PC and they are connected. 我确实设置了Android和PC,并且它们已连接。 When I open my remote devices in chrome, my Phone is connected. 当我打开Chrome中的远程设备时,手机已连接。 I can also open a normal url from the tool and it will open in my phone. 我也可以从该工具中打开普通网址,该网址会在我的手机中打开。

But I am not able to open a domain which I have set in my environment like this: 但是我无法打开在我的环境中设置的域,如下所示:

127.0.0.1 wptest.local 127.0.0.1 wptest.local

I would now like to op this URL: http://wptest.local/wordpress/ in my phone, but I get: ERR_NAME_NOT_RESOLVED. 我现在想在手机中使用以下URL: http://wptest.local/wordpress/ ,但得到:ERR_NAME_NOT_RESOLVED。

I get an Apache notice "Object not found" when entering: 输入时,我收到一个Apache通知“找不到对象”:

192.168.178.21/wptest.local/ 192.168.178.21/wptest.local/

so I am close I guess? 所以我猜我很近吗?

I have read through this question but can not figure out what to do: How can I access my localhost from my Android device? 我已经阅读了此问题,但无法弄清楚该怎么办: 如何从Android设备访问本地主机?

I hope someone can explain me what to do to get access to my localhost domain? 我希望有人可以向我解释如何访问我的本地主机域?

Edit to clarify a bit: My PC and Android are connected by USB to the same WIFI and I am able to get to the localhost. 编辑以澄清一点:我的PC和Android通过USB连接到相同的WIFI,并且能够进入本地主机。 That is, when I insert my IP4 address, it will go to the first "localhost name resolution" in my hosts file. 也就是说,当我插入IP4地址时,它将转到主机文件中的第一个“本地主机名称解析”。 That is now: 127.0.0.1 wptest.local 现在是:127.0.0.1 wptest.local

In my httpd-vhosts.conf, I have this code: 在我的httpd-vhosts.conf中,有以下代码:

<VirtualHost *:80>
    ServerName wptest.local
    DocumentRoot C:/xampp/htdocs/wptest/public

    SetEnv APPLICATION_ENV "development"

    <Directory C:/xampp/htdocs/wptest/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

The folder for my site is: C:\\xampp\\htdocs\\wptest\\public\\wordpress 我的站点的文件夹是:C:\\ xampp \\ htdocs \\ wptest \\ public \\ wordpress

In there is the index.php file. 里面有index.php文件。

When I enter my IPV I do get: Index of / and the wordpress folder on my phone. 当我输入IPV时,会得到:/的索引以及手机上的wordpress文件夹。 But I can not get any further. 但是我无法再进一步了。 As soon as I choose that wordpress folder and hoping to open the index.php file in there, it resolves to: wptest.local/wordpress/ and that can not be found. 一旦我选择了那个wordpress文件夹并希望在那里打开index.php文件,它就会解析为:wptest.local / wordpress /而找不到。

Clearly I am new to this stuff, but hope that this clarifies it a bit. 显然,我是新手,但是希望这能使您有所了解。

It's simple 这很简单

1.just turn on your mobile hotspot 1.打开手机热点

 2. connect your pc or laptop to your mobile hotspot. (connect your mobile and pc/laptop to the same router).

 3. open command prompt.
 4. type ipconfig and enter.
 5. copy your ipv4 address.
 6. replace your server address with your copied address.
 7. and run your project.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM