Please point me in the right direction.
I am using .htaccess to set-up domains on my server.
I need to domain.com to access files from /domain.com/* folder. If a file does not exist, load /domain.com/index.php and domain.com/images/image.jpg should load file: /domain.com/images/image.jpg
One thing is that it should load everything without sending 302 "file moved" notices to browser.
Thanks for your help!
If you have a lot of domains, or even if you have only a few domains but they all have more or less the same configuration, this is the kind of situation that dynamic mass virtual hosting is made for. Something like this would go in your
httpd.conf
file (or in a file that's included inhttpd.conf
):I'd also suggest
to load the
index.php
file in a directory if the client doesn't specify a filename.You should create a virtual host for every single domain you'd like to map to a file path, and specify the DocumentRoot of each vhost to the actual path on the filesystem. Then, you'll want to be sure you have a DEFAULT vhost, so that all other requests for domains that are not setup, will use the DEFAULT vhost. Lastly, you'll want to create a custom 404 error handler, so that if the file does not exist that is being requested, it will serve up alternative content. You will need to create a php called custom_404.php that displays a generic message and your /images/image.png.
Hope this helps!
-Kevin
You need to use virtual hosts to organize this. Here is a sample virtual host file.
Place this file inside /etc/httpd/conf.d/ And call it for example, vhost_example.net.conf
And then add inside /etc/httpd/conf/httpd.conf in for example the last line
Include /etc/httpd/conf.d/vhost_example.net.conf
(or just Include /etc/httpd/conf.d/*.conf ) And in httpd.conf file, remember to make this line uncommented
NameVirtualHost *:80