【问题标题】:Can not access Apache server from LAN无法从局域网访问 Apache 服务器
【发布时间】:2017-06-26 16:48:47
【问题描述】:

我已经尽一切努力让它工作,但我仍然无法从我的局域网访问我的网站(本地主机)。 我正在使用 Apache2.4 和 PHP7.1。 奇怪的是,当我在手机上输入我的计算机 IP 后,URL 从“ip”变为“www.ip/”(我有一个 .htaccess 文件)但给了我错误 ERR_NAME_NOT_RESOLVED。我正在使用 Chrome。

DirectoryIndex  index.php
RewriteEngine on
RewriteRule ^(\w+)$ index.php?page=$1 [L,NC,QSA]
RewriteRule ^(\w+)+\/$ index.php?page=$1 [L,NC,QSA]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

order allow,deny
deny from 46.101.200.204
allow from all

【问题讨论】:

  • 我会说您需要摆脱最后一个 RewriteRule,或者为您的服务器设置一个域名,而不是通过直接 IP 访问。目前的规则是,如果您使用 IP 进入,则将您重定向到损坏的 URL,正如您所看到的那样。
  • 不起作用...
  • 以什么方式不起作用?你现在看到了什么行为?
  • 我关闭了重写引擎,我仍然无法通过手机访问网站。
  • @KarlReid 你有什么线索吗?

标签: apache .htaccess server


【解决方案1】:

如果您要通过 mod_rewrite 坚持使用该名称,请在客户端的 hosts 文件中添加“www.ip”。如果您决定停止这样做,您还需要清除浏览器缓存,因为您选择了永久重定向。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-07
    • 1970-01-01
    • 2014-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-04
    • 2017-07-21
    相关资源
    最近更新 更多