: CSS and JS are loaded from the IP address rather than from the appropriate subdomain host name I have one VM (LAMP) with a static IP. There are two Subdomains configured on this Machine. If
I have one VM (LAMP) with a static IP. There are two Subdomains configured on this Machine. If i browse one of the subdomains, it executes the files specified in its DocumentRoot. The problem here is there are no sources loaded (CSS, JS, ...) because it loads em from the IP-Addres/Path but that cant be working since i need the subdomain to specify the correct DocumentRoot.
Example:
192.168.10.10 goes to /var/www/
sub.mydomain.com goes to /var/www/sub/
dom.mydomain.com goes to /var/www/dom/
the Scripts loaded by the site on sub.mydomain.com are loaded from 192.168.10.10/css/default.css which obviously can't be working.
Where do i need to place changes to get this working? (Also the Form-Redirects after submitting are mapping to the ServerIP)
Is this part of the VirtualHosts-Section in Apache-Conf or the .htaccess-File?
Apache-Site-Configuration:
NameVirtualHost *:80
NameVirtualHost *:443
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName sub.mydomain.com
ServerAlias sub.mydomain.com
DocumentRoot /var/www/sub/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
#RewriteEngine on
#RewriteCond %{SERVER_PORT} ^80$
#RewriteRule ^(.*)$ %{SERVER_NAME} [L,R]
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName sub.mydomain.com
ServerAlias sub.mydomain.com
DocumentRoot /var/www/sub/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/sub/>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain text/html text/xml
AddOutputFilterByType DEFLATE text/css text/javascript
AddOutputFilterByType DEFLATE application/javascript application/x-javascript
</IfModule>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/wildcard_mydomain.cert
SSLCertificateKeyFile /etc/apache2/ssl/wildcard_mydomain.key
SSLCertificateChainFile /etc/apache2/ssl/wildcard_mydomain.intermediate
</VirtualHost>
And my .htaccess-File:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ajax/(.*)$ ajax.php?shform= [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?shform= [QSA,L]
More posts by @Cody1181609
1 Comments
Sorted by latest first Latest Oldest Best
The only way that the CSS and JS would be loaded from an IP address is if the HTML code specifies that. You will need to change your HTML code from:
<link rel="stylesheet" type="text/css" href="http://192.168.10.10/css/default.css">
to a relative link:
<link rel="stylesheet" type="text/css" href="/css/default.css">
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.