Home > Software design >  404 for image folder after redirect, but site works properly
404 for image folder after redirect, but site works properly

Time:11-09

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

CodePudding user response:

DocumentRoot /var/www/html/omeka-s

... I have a folder on the same level of my omeka s installation with the item images

I assume the folder omeka-s is your "omeka s installation" in which case, your DocumentRoot would seem to be set incorrectly for the URL you are requesting assuming images and omeka-s are two folders "on the same level".

With the document root as set above, a request for https://myredirect.it/images/Albini would be looking for /var/www/html/omeka-s/images/Albini, whereas it should presumably be /var/www/html/images/Albini.

For example, it should probably be set as follows instead:

DocumentRoot /var/www/html

And you will need to adjust the <Directory> container (assuming you have one) accordingly.

UPDATE: You presumably have a <Directory> container that follows that permits access, allows .htaccess overrides, sets Options etc. This <Directory> container should reference the correct document root also (not /var/www/html/omeka-s). For example:

<Directory /var/www/html>
    :
    :
</Directory>

CodePudding user response:

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

  • Related