WAMP 的远程访问重定向到重复的 url
Posted
技术标签:
【中文标题】WAMP 的远程访问重定向到重复的 url【英文标题】:Remote access of WAMP redirects to duplicate url 【发布时间】:2018-06-11 01:59:52 【问题描述】:当我从本地网络上的远程设备访问 WordPress 网站时,即:www.test.local WAMP 决定将此请求重定向到看起来像 www.test.local 的 url http/www.test.local/ 我会得到一个错误。但是,当我从主计算机(使用 WAMP)访问 url 时,不会发生重定向。我试图删除主要的 wordpress htaccess。 如果网站只有 index.html,则不会出现此问题。
我从错误日志中得到的所有信息:
[www.test.local/sid#1a426ce7a18][rid#1a432dc9390/initial] [perdir C:/Users/MyUser/work/test/www/] strip per-dir prefix: C:/Users/MyUser/work/test/www/ ->
[www.test.local/sid#1a426ce7a18][rid#1a432dc9390/initial] [perdir C:/Users/MyUser/work/test/www/] applying pattern '^index\\.php$' to uri ''
[www.test.local/sid#1a426ce7a18][rid#1a432dc9390/initial] [perdir C:/Users/MyUser/work/test/www/] strip per-dir prefix: C:/Users/MyUser/work/test/www/ ->
[www.test.local/sid#1a426ce7a18][rid#1a432dc9390/initial] [perdir C:/Users/MyUser/work/test/www/] applying pattern '.' to uri ''
[www.test.local/sid#1a426ce7a18][rid#1a432dc9390/initial] [perdir C:/Users/MyUser/work/test/www/] pass through C:/Users/MyUser/work/test/www/
[www.test.local/sid#1a426ce7a18][rid#1a4296ec5d0/subreq] [perdir C:/Users/MyUser/work/test/www/] strip per-dir prefix: C:/Users/MyUser/work/test/www/index.php -> index.php
[www.test.local/sid#1a426ce7a18][rid#1a4296ec5d0/subreq] [perdir C:/Users/MyUser/work/test/www/] applying pattern '^index\\.php$' to uri 'index.php'
[www.test.local/sid#1a426ce7a18][rid#1a4296ec5d0/subreq] [perdir C:/Users/MyUser/work/test/www/] pass through C:/Users/MyUser/work/test/www/index.php
[www.test.localhttp/sid#1a426ce7a18][rid#1a4334b9cc0/initial] [perdir C:/Users/MyUser/work/test/www/] add path info postfix: C:/Users/MyUser/work/test/www/www.test.local -> C:/Users/MyUser/work/test/www/www.test.local/
[www.test.localhttp/sid#1a426ce7a18][rid#1a4334b9cc0/initial] [perdir C:/Users/MyUser/work/test/www/] strip per-dir prefix: C:/Users/MyUser/work/test/www/www.test.local/ -> www.test.local/
[www.test.localhttp/sid#1a426ce7a18][rid#1a4334b9cc0/initial] [perdir C:/Users/MyUser/work/test/www/] applying pattern '^index\\.php$' to uri 'www.test.local/'
[www.test.localhttp/sid#1a426ce7a18][rid#1a4334b9cc0/initial] [perdir C:/Users/MyUser/work/test/www/] add path info postfix: C:/Users/MyUser/work/test/www/www.test.local -> C:/Users/MyUser/work/test/www/www.test.local/
[www.test.localhttp/sid#1a426ce7a18][rid#1a4334b9cc0/initial] [perdir C:/Users/MyUser/work/test/www/] strip per-dir prefix: C:/Users/MyUser/work/test/www/www.test.local/ -> www.test.local/
[www.test.localhttp/sid#1a426ce7a18][rid#1a4334b9cc0/initial] [perdir C:/Users/MyUser/work/test/www/] applying pattern '.' to uri 'www.test.local/'
[www.test.localhttp/sid#1a426ce7a18][rid#1a4334b9cc0/initial] [perdir C:/Users/MyUser/work/test/www/] RewriteCond: input='C:/Users/MyUser/work/test/www/www.test.local' pattern='!-f' => matched
[www.test.localhttp/sid#1a426ce7a18][rid#1a4334b9cc0/initial] [perdir C:/Users/MyUser/work/test/www/] RewriteCond: input='C:/Users/MyUser/work/test/www/www.test.local' pattern='!-d' => matched
[www.test.localhttp/sid#1a426ce7a18][rid#1a4334b9cc0/initial] [perdir C:/Users/MyUser/work/test/www/] rewrite 'www.test.local/' -> '/index.php'
[www.test.localhttp/sid#1a426ce7a18][rid#1a4334b9cc0/initial] [perdir C:/Users/MyUser/work/test/www/] trying to replace prefix C:/Users/MyUser/work/test/www/ with /
[www.test.localhttp/sid#1a426ce7a18][rid#1a4334b9cc0/initial] [perdir C:/Users/MyUser/work/test/www/] trying to replace context docroot c:/Users/MyUser/work/test/www with context prefix
[www.test.localhttp/sid#1a426ce7a18][rid#1a4334b9cc0/initial] [perdir C:/Users/MyUser/work/test/www/] internal redirect with /index.php [INTERNAL REDIRECT]
[www.test.localhttp/sid#1a426ce7a18][rid#1a4334a4b68/initial/redir#1] [perdir C:/Users/MyUser/work/test/www/] strip per-dir prefix: C:/Users/MyUser/work/test/www/index.php -> index.php
[www.test.localhttp/sid#1a426ce7a18][rid#1a4334a4b68/initial/redir#1] [perdir C:/Users/MyUser/work/test/www/] applying pattern '^index\\.php$' to uri 'index.php'
[www.test.localhttp/sid#1a426ce7a18][rid#1a4334a4b68/initial/redir#1] [perdir C:/Users/MyUser/work/test/www/] pass through C:/Users/MyUser/work/test/www/index.php
[www.test.localhttphttp/sid#1a426ce7a18][rid#1a4426f31f0/initial] [perdir C:/Users/MyUser/work/test/www/] add path info postfix: C:/Users/MyUser/work/test/www/www.test.localhttp -> C:/Users/MyUser/work/test/www/www.test.localhttp/www.test.local/
[www.test.localhttphttp/sid#1a426ce7a18][rid#1a4426f31f0/initial] [perdir C:/Users/MyUser/work/test/www/] strip per-dir prefix: C:/Users/MyUser/work/test/www/www.test.localhttp/www.test.local/ -> www.test.localhttp/www.test.local/
我的虚拟主机文件:
<VirtualHost *:80>
ServerName localhost2.local
ServerAlias *.*.local
VirtualDocumentRoot "c:/Users/MyUser/work/%2/%1/"
<Directory "c:/Users/MyUser/work/">
ServerSignature Off
Options Indexes FollowSymLinks IncludesNoExec
AllowOverride All
Order allow,deny
Allow from all
# Insert the following:
Require all granted
</Directory>
</VirtualHost>
如果我将使用标准 WP 生成的 .htaccess :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_FILENAME !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
结果是 URL 被重定向到 www.test.localhttphttphttp... 等,直到达到限制... 在远程设备上是 WAMP pc IP 作为代理。 知道重定向的来源吗?
编辑: 更新日志 - 这是显示重写跟踪的内容。从 localhost 机器访问时,直到第 9 行之前都是一样的,然后它像往常一样调用资产等...
【问题讨论】:
您能否更新您的问题以包含 .htaccess 文件? @Ben .htaccess 添加到问题中。 Apache 版本是 2.4.23... 您可以从设备访问 *.local 域中的其他网站吗? 192.168.0.3是远程设备ip吗? 如果您将此 .htaccess 重命名为其他名称,这个问题会消失吗? 【参考方案1】:编辑:这似乎不是问题,因为问题的更新清楚地表明了这一点。仍然将其留给可能会发现它有用的随机谷歌用户。
要更新您的 wordpress 网站的 URL:
您可以在 wp_options 表中将option_name
的“home”和“siteurl”更新为“http://www.test.local/”的option_value
(两者的值相同) -
UPDATE [yourWPDB].wp_options
SET option_value='http://www.test.local/'
WHERE option_name = 'home' OR option_name = 'siteurl'
您还可以在您的 wordpress 根目录中添加以下行到您的 wp-config.php 文件中进行更新 -
define('WP_SITEURL', 'http://www.test.local/');
define('WP_HOME', 'http://www.test.local/');
【讨论】:
【参考方案2】:您必须在 wordpress 配置中更新您的网站 url 和域名。这被保存为一个我不记得名字的表中的序列化数据。
最简单的修复方法是编辑 index.php 并在最后添加:
update_option( 'siteurl', 'http://www.test.local' );
update_option( 'home', 'http://www.test.local' );
打开您的网站,这将更新您的 wordpress 配置。然后您可以删除这些行并保留 index.php 原样。
清除浏览器缓存或使用隐身模式并打开 www.test.local
【讨论】:
似乎不是问题...当脚本到达可以更新的位置时,站点已经被重定向,并且我在 wp-config.php 中定义了这些选项...更新的我在答案中输入的日志可能会告诉更多... 您可能缓存了重定向。尝试使用其他浏览器或隐身模式【参考方案3】:尝试更新选项值 'siteurl'=>'http://www.test.local' ); 'home'=>'http://www.test.local' 来自数据库(wp_options)表,并且不要在 url 末尾放置斜杠。例如www.test.local/..reset 来自后端的永久链接
【讨论】:
以上是关于WAMP 的远程访问重定向到重复的 url的主要内容,如果未能解决你的问题,请参考以下文章