无法通过移动浏览器访问本地主机上的Wordpress网站(Chrome开发者工具-远程设备) [英] Can't access to Wordpress site on localhost via mobile browser (Chrome devtools - remote devices)
问题描述
我无法从移动浏览器访问本地主机上的wordpress网站.
I can't access to wordpress site on localhost from mobile browser.
我已将手机连接到Chrome远程设备,并且可以访问XAMPP仪表板
I have connected my phone to the Chrome remote devices and I can access to the XAMPP dashboard
localhost:8080/dashboard
但是,当我尝试对存储在 htdocs/mysite
文件夹中的wordpress网站执行相同操作时,在这种情况下,移动浏览器无法访问它(但在桌面浏览器中,只需键入 localhost/mysite
(不带任何端口).
but when I am trying to do the same with a wordpress site which stored in folder htdocs/mysite
in this case the mobile browser can't reach it (but desktop browser can when simply type localhost/mysite
without any ports).
此外,移动浏览器中的URL已从 localhost:8080/mysite
覆盖为 localhost/mysite
And in addition the URL in mobile browser is being overridden from localhost:8080/mysite
to localhost/mysite
注意:我可以从移动浏览器访问所有静态网站或具有自定义CMS的网站.但是wordpress CMS存在问题.
Note: I can access all static websites or websites with custom CMS from mobile browser. But there is an issue with wordpress CMS.
这是来自WP的标准.htaccess
Here is a standard .htaccess from WP
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /mysite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mysite/index.php [L]
</IfModule>
# END WordPress
我尝试了各种示例来解决我的问题.但没有成功.例如,如果我在移动浏览器中键入 127.0.0.1:8080/mysite
,则devtools控制台中会出现空白页和一堆错误(对于所有资源:css,js等):>
I have tried a various examples to solve my problem.
but unsuccessfully. For example if I type 127.0.0.1:8080/mysite
in mobile browser then there is a blank page and bunch of errors in the devtools console (for all resources: css, js etc.):
GET http://localhost/mysite/wp-content/themes/mytheme/assets/css/bootstrap.min.css net::ERR_CONNECTION_REFUSED
欣赏所有提示
推荐答案
您需要将phpmyadmin中wp_options中的站点url和home值从"localhost"更改为要访问的网址.对我来说,我正在从Url'192.168.1.4'访问我的本地主机,并且在这种情况下,它将我重定向到本地主机.
You need to change your site url and home value in wp_options in phpmyadmin from 'localhost' to your accessing Url. For me i am accessing my localhost from Url '192.168.1.4' and it redirects me to localhost if this is the case.
我将网站网址和首页网址从" http://localhost/mysite "修改为" http://192.168.1.4/mysite ".在您的情况下,您可以像' http://localhost:8080/mysite '进行编辑.
I edited my site url and home url from 'http://localhost/mysite' to 'http://192.168.1.4/mysite'. in your case you can edit like 'http://localhost:8080/mysite'.
这篇关于无法通过移动浏览器访问本地主机上的Wordpress网站(Chrome开发者工具-远程设备)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!