-1

I can host a website using Alias.

Than the URI look like: www.myside.com/alias

I achive this using this in /etc/apache2/sites-available/www.myside.com.conf

 Alias /alias"/usr/local/tomcat/alias"
 <Directory "/usr/local/tomcat/alias">
     Options -Indexes -FollowSymLinks
     AllowOverride AuthConfig
     Require all granted
 </Directory>

What I need is that I'm able to host the main context with this: www.myside.com and an image context with the alias, looking like this: www.myside.com/userimg. So I only need the main <Directory></Directory> block without the alias.

By the way, I'm using JKmount.

The image context:

 Alias /userimg "/usr/local/tomcat/userimg"
      <Directory "/usr/local/tomcat/userimg">
         Options -Indexes -FollowSymLinks
         AllowOverride AuthConfig
         Require all granted
      </Directory>
ru4ert
  • 998
  • 2
  • 14
  • 25

1 Answers1

2

Reading your question, I assume that:

  • your site is not SSL.

  • therefore it will use port 80

  • you have a site, lets say http://www.example.com

  • the files for your site are stored in /usr/local/tomcat/alias

  • the main page for your site is index.html, under /usr/local/tomcat/alias

  • the image files for your site are sorted in /usr/local/tomcat/userimg

  • in your HTML files, you reference other pages like this:

    <a href="otherpage.html">Other page</a>
    
  • you reference images like this:

    <img src="userimg/someimage.png" alt="Some Image">
    

Your configuration would look like this:

<VirtualHost *:80>
    ServerName www.example.com
    ServerAlias example.com

    ErrorLog "logs/error_log"
    CustomLog "logs/access_log" combined

    DocumentRoot "/usr/local/tomcat/alias"
    DirectoryIndex index.html

    Alias "/userimg" "/usr/local/tomcat/userimg"

    <Directory "/usr/local/tomcat/alias">
        Options -Indexes -FollowSymLinks
        AllowOverride AuthConfig
        Require all granted
    </Directory>

</VirtualHost>

If you want to avoid any Alias at all, you could create a softlink in /usr/local/tomcat/alias to /usr/local/tomcat/userimg.

cd /usr/local/tomcat/alias
ln -s /usr/local/tomcat/userimg userimg

And you will have to allow Apache to follow links in the <Directory> directives.


Or you could move your images under /usr/local/tomcat/alias/userimg.

Nic3500
  • 8,144
  • 10
  • 29
  • 40