Search code examples
apachehttp-redirectomeka

404 for image folder after redirect, but site works properly


I have an Omeka S installation and it's all working properly, I made the redirect in apache in the sites-available folder, no problem with that.

In the same server I have a folder on the same level of my omeka s installation with the item images. When I want to load medias and I write the url of where to find the images I'll get a 404 error. If I type wget and the url of where the images where to be found I get:

wget http://mysite.it/images/Albini
--2021-11-02 10:58:51--  http://mysite.it/images/Albini
Resolving mysite.it (mysite.it)... 127.0.1.1
Connecting to mysite.it (mysite.it)|127.0.1.1|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://myredirect/images/Albini [following]
--2021-11-02 10:58:51--  https://myredirect/images/Albini
Resolving myredirect (myredirect)... 160.78.46.107
Connecting to myredirect (myredirect)|160.78.46.107|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2021-11-02 10:58:51 ERROR 404: Not Found.

How can I resolve this?

This is the config in 000-default.config:

<VirtualHost *:80>
        
        ServerName myredirect.it
        Redirect / https://myredirect.it/

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/omeka-s

and this is the config in default-ssl.conf:

<IfModule mod_ssl.c>
        <VirtualHost _default_:443>

                ServerName myredirect.it
                ServerAdmin webmaster@localhost

                DocumentRoot /var/www/html/omeka-s

Solution

  • Ok, I figured it out. I just needed to set an alias and gives permissions, without changing the DocumentRoot, like that (in the 000-default.conf and default-ssl.conf:

    AliasMatch "^/images/(.*)" "/var/www/html/images/$1"
    
    
    <Directory /var/www/html/images/>
        Order allow,deny
        Allow from all
    </Directory> 
    

    It was well documented in https://httpd.apache.org/docs/2.4/mod/mod_alias.html