Score:0

Apache Virtual Hosts - Map different paths of the same domain to different sites

cn flag

I a running Apache/2.4.41 (Ubuntu)

I want to use only one domain name.

I would like to map different sites to different paths after the domain name.

For example:

mydomain.com/test001 maps to /var/www/test001/public

mydomain.com/test002 maps to /var/www/test002/public

I've already tried many different virtual host configurations but none of them worked.

so now I am trying to map mydomain.com/test002 to /srv/public , as below:

Alias /test002 /srv/test002/public_html

<Directory /srv/test002 /public_html>

   Order Allow,Deny

   Allow from all

   Options FollowSymLinks

</Directory>

the first site woks but the second site index page only works and if I tried to redirect to another page it will give '404 page not found'

the .htaccess of the second site is :

RewriteEngine On

RewriteBase /test002/

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule !.(js|css|eot|svg|ttf|woff|woff2|map)$ index.php [L]

RewriteCond $1 !^(index\.php|assets)

It is very weird, I have been working on it all day and no solution yet and couldn't find anything helpful on the web.

can anyone help me please?

David avatar
cn flag
What version of Ubuntu?
Kareem Osman avatar
cn flag
VERSION="20.04.2 LTS (Focal Fossa)"
zwets avatar
us flag
Is there a specific reason why you aren't using `Alias /test001/ /var/www/html/test001/public/` to do this?
Kareem Osman avatar
cn flag
I tried doing as above but I get 'permission denied ' as a response even when all the permissions needed are granted
in flag
I am unfamiliar with `/srv` as a directory. If this is one that you've created on your own, you will want to ensure that AppArmor recognises it as a location for Apache to read/write. Otherwise, Apache will be limited to only the directories within `/var/www`
Kareem Osman avatar
cn flag
you can enable /srv directory in apache.conf by uncommenting this code: <Directory /srv/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
Score:0
cn flag

I solve the problem by adding to the options in the directory :

Options +Indexes +followSymLinks

so it looks like this:

<Directory /srv/test002/public_html>

Order Allow,Deny

Allow from all

Options +Indexes +followSymLinks

</Director

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.