Reputation:
I'm trying to setup a Virtual Host (let's say "subdomain1.domain.com") on Apache/2.4.6 (CentOS). The web server does not have a hostname, IP address let's say is 55.55.55.55, Apache is listening at port 80. I have a redirect service active and the requests for "subdomain1.domain.com:80" are redirected to http://55.55.55.55/.
DocumentRoot is "/var/www/html" as per httpd.conf.
The website public content is in a directory named "subdomain1" which I'm placing inside the /var/www/html directory. The website code makes use of some JS/CSS which should be in common with the other virtual hosts I would like to create later, so I place the JS/CSS in a directory "libraries" located outside the WebSite Document Root (means, inside "/var/www/html"), and I'm tryng to give them access from the html code by a "../libraries/".
Virtual Host configuration file is a "subdomain1.conf" placed in /etc/httpd/conf.d/" directory, this is the file:
<VirtualHost *:80>
ServerName subdomain1.domain.com
DocumentRoot /var/www/html/subdomain1
</VirtualHost>
Now, with this configuration I can reach the website of Subdomain1 at http://subdomain1.domain.com. The public content of Subdomain1 is reachable, but.. the problem is: all the JS/CSS are not found by Apache and they all return a 404 error. While debugging with the web browser I see the path where Apache is searching the JS/CSS library is "http://55.55.55.55/libraries/" and this returns 404.
Any idea where I'm doing wrong ?
Many thanks ! Mic
Upvotes: 0
Views: 1024
Reputation: 21
Here are some suggestions from me.
Setting FQDN of your server FQDN
$ nano /etc/hosts
55.55.55.55 subdomain1.domain.com subdomain1
Setting your server hostname
$ nano /etc/hostname
subdomain1.domain.com
Enable mod_rewrite on the apache webserver
Create an .htaccess file below and save it into the folder /var/www/html/subdomain1/
< IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] < /IfModule>
Thank you, Afrizal
Upvotes: 0