My server's structure is like this:
|- var
|-- www
|--- website1
|--- website2
|--- website3
I'm currently working on website1
, but I found that when I submit one of my Ajax forms, it returns the following error:
http://www.website.com/signup: The requested URL /signup was not found on this server.
When it should be looking under http://www.website.com/website1/signup
instead.
Here's what I currently have added in my apache2.conf
:
Alias /website1 "/var/www/website1/public"
<Directory /var/www/website1>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
And my DocumentRoot
is set to /var/www
in my VirtualHosts. How can I fix this?
This can't work. You confuse the Alias
directive with a Virtual Host
.
What you call www.website1.com
is a hostname, not a directory part of the url. Therefore the Alias directive will not catch. An Alias directive allows you to map something like http://www.website.com/folder1 to an arbitrary location inside your local file system by means of a directive like Alias /folder1 ...
. Not more. It does not see the requested host, since it is located inside a host configuration.
Instead you need a Virtual Host for each hostname / domain name you want to serve content for. If you have no virtual hosts setup yet, then the http server will fall back to the default host, which is what you call www.website.com
.
All options of the apache http server are documented in excellent quality. I suggest you take a look into that documentation: http://httpd.apache.org/docs/2.2/vhosts/
To be precise here: what you describe can actually be done by means of url rewriting. But it would be a pain and very intransparent. Virtual hosts are the way to go.