Stylesheets don't load on remote access
Posted by: seanfilidis (---.cable.dynamic.v4.ziggo.nl)
Date: February 19, 2018 09:30PM

Hey guys,

I'm trying to make my project accessible to other devices on my local network.

When I access my website via another device, the page loads, but with no styling, and I can't figure out why.

It's a wordpress site.

Here is the contents of my httpd-vhosts.config. The first entry I left as is. The second entry is so that I can access my project on the same computer more easily. The third entry is my attempt to make it remotely accessible.

# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName 30days.here
ServerAlias 30days.here
DocumentRoot "${INSTALL_DIR}/www/wordpress/"
<Directory "${INSTALL_DIR}/www/wordpress/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

<VirtualHost 192.168.178.185:80>
DocumentRoot "${INSTALL_DIR}/www/wordpress/"
<Directory "${INSTALL_DIR}/www/wordpress/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>


In my httpd.conf I changed my server name from localhost to my IP address, 192.168.178.185, and I set Require all granted.

Any clue what I'm doing wrong?

Again, if I navigate to 192.168.178.185 from another device, the page loads, but the stylesheets don't.

Thanks for the help.

Options: ReplyQuote
Re: Stylesheets don't load on remote access
Posted by: Otomatic (Moderator)
Date: February 20, 2018 09:45AM

Hi,

What I can already say is that your VirtualHost has not been created or added by the tool integrated in Wampserver ('http://localhost/add_vhost. php'); if that had been the case, there would be no errors.

> DocumentRoot "${INSTALL_DIR}/www/wordpress/"
Don't put any trailing slash on the path to DocumentRoot.
See http://httpd.apache.org/docs/2.4/en/mod/core.html#documentroot

> <VirtualHost 192.168.178.185:80>
Where is ServerName for this VirtualHost?
If no ServerName is specified, the server attempts to deduce the client visible hostname by first asking the operating system for the system hostname, and if that fails, performing a reverse lookup on an IP address present on the system.

> In my httpd.conf I changed my server name from localhost
> to my IP address, 192.168.178.185,
Except for very special (and very rare) cases, you don't have to modify httpd.conf "by hand"; the tools built into Wampserver do it wherever you need to do it.

And, with all your "by hand" modifications, have you modified the C:\Windows\System32\drivers\etc\hosts file as it should be?
Because there too, the tools built into Wampserver do it very well, even with VirtualHost over IP.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Stylesheets don't load on remote access
Posted by: seanfilidis (---.cable.dynamic.v4.ziggo.nl)
Date: February 20, 2018 09:04PM

Thanks for your reply.

Okay, I reverted all my changes:
- Deleted the extra entries I made to httpd-vhosts.conf
- Changed my server name back to localhost:80 in httpd.conf
- Deleted entry I had made to my hosts file

I now used the WAMP Virtual Hosts tool to add an entry:
- It would not let me use my IP address as a server name, so I just entered 'test'.
- I set the path to C:/wamp64/www/wordpress

Now, my vhosts file looks like this:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>


#
<VirtualHost *:80>
ServerName test
DocumentRoot "c:/wamp64/www/wordpress"
<Directory "c:/wamp64/www/wordpress/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

I see it automatically added the following lines to my hosts file as well:

127.0.0.1 test
::1 test

So, now, I can enter [test] and get to my project as long as I am on the same computer. But this doesn't help me.

I want to access my project from other devices on the network via my server's IP. Right now, if I type 192.168.178.185 into a browser on another device, I get a 403 Forbidden error.

What am I missing?



Edited 1 time(s). Last edit at 02/20/2018 09:27PM by seanfilidis.

Options: ReplyQuote
Re: Stylesheets don't load on remote access
Posted by: Otomatic (Moderator)
Date: February 20, 2018 09:45PM

Hi,

For access from LAN, for your VitualHost test replace :

Require local

by

Require local
Require ip 192.168

(if 192.168.0.0 to 192.168.255.255 is the range of IP's from your LAN devices)

From LAN devices you have to type 'http://192.168.178.165/test/'

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Stylesheets don't load on remote access
Posted by: seanfilidis (---.cable.dynamic.v4.ziggo.nl)
Date: February 20, 2018 10:51PM

Hey,

Made the edit. Restarted WAMP.

Still getting 403 Forbidden at 192.168.178.185/test from other devices on the LAN.

Options: ReplyQuote
Re: Stylesheets don't load on remote access
Posted by: Otomatic (Moderator)
Date: February 21, 2018 09:11AM

Hi,

Try to replace:
<VirtualHost *:80>
  ServerName test
  DocumentRoot "c:/wamp64/www/wordpress"
  <Directory "c:/wamp64/www/wordpress/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>
by
<VirtualHost *:80>
  ServerName test
  DocumentRoot "c:/wamp64/www/wordpress"
</VirtualHost>

<Directory "c:/wamp64/www/wordpress/">
  Options +Indexes +Includes +FollowSymLinks +MultiViews
  AllowOverride All
  Require local
</Directory>

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Stylesheets don't load on remote access
Posted by: seanfilidis (---.cable.dynamic.v4.ziggo.nl)
Date: February 21, 2018 07:56PM

Well, that did something.

Now, when I navigate to 192.168.178.185/wordpress from another device, like my iPad, it redirects to localhost/wordpress.

Obviously, there is no localhost/wordpress on my iPad, so it just says site can't be reached.



Edited 1 time(s). Last edit at 02/21/2018 07:56PM by seanfilidis.

Options: ReplyQuote
Re: Stylesheets don't load on remote access
Posted by: RiggsFolly (Moderator)
Date: February 22, 2018 12:29AM

This is totally wordpress. As it was installed into localhost/wordpress it remembers that url and uses in on all sorts of urls and links.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Stylesheets don't load on remote access
Posted by: seanfilidis (---.cable.dynamic.v4.ziggo.nl)
Date: February 22, 2018 08:45AM

That's what was missing!

I set WP_HOME and WP_SITEURL to 192.168.178.185/wordpress in my wp-config file, and now it works.

I can't believe how many websites I visited, posts I read, and videos I watched. None of them could provide full working instruction.

Thanks guys.

Options: ReplyQuote


Sorry, only registered users may post in this forum.