Images with colon in the path not being served on Apache - apache

Apache is not serving images with a colon in the image path. It works on one server, but not on a new one. Assuming there's a config issue. What is the solution to this?

Related

Can I use DigitalOcean Spaces CDN as MediaServer in Prestashop?

My prestashop is hosted on a DigitalOcean droplet. I want to use DigitalOcean Spaces as a MediaServer in my shop.
But if I set up the spaces origin (https://xxxxxxxx.fra1.cdn.digitaloceanspaces.com) as MediaServer in Prestashop, then my images are missing.
In the product page source, the img src seems to be right, it points to the CDN address.
The main problem is, that prestashop dont sync my images to the CDN.
I have tried Bunny CDN before, and it was ok. The images were uploaded automatically.
How should I set up DigitalOcean Spaces to work like Bunny CDN?
There are 2 sides to it.
Prestashop Images storeage
Pointing to a CDN from Prestashop.
Prestashop only knows about the prestashop/img directory, where it stores all of the images.
From a DigitalOcean Droplet, you can mount a DigitalOcean Spaces just like a file system.
Please check here:
https://www.digitalocean.com/community/questions/how-to-mount-digitalocean-spaces-on-droplets-with-s3fs
Once you have mounted your DO Spaces say as /storage/DO_Spaces. You can simply rename your prestaship/img directory to prestashop/img_backup
and can use a soft link to point img to DO spaces mounted on your droplet.
Assuming /var/www/prestashop is the directory where prestashop is installed.
go to prestashop directory and create a soft link.
ln -s /storage/DO_Spaces /var/www/prestashop/img
now copy entire prestaship/img_backup to prestashop/img directory
cp -rf /var/www/prestashop/img_backup /var/www/prestashopprestashop/img/
WIthin seconds, you will see your images on your DO Spaces.
2nd step is to be able to view your images from a browser from the DO Spaces and its CDN. For this create a CNAME pointer to your CDN as mentioned above.
On your prestashop computer copy an image to /var/www/prestashop/img directory and check that you can view this file from http://static.mywebsite.com/image.png. You have to make sure that the root of your DO Spaces serves as the img directory.
Now every time prestashop will create an image in the /var/www/prestashop/img directory, it will be automatically copied to the DO Spaces and will be visible from your static URL. You will need to set correct permissions on DO Spaces that all new files become visible to the world.
More on this how to make your files visible or readable is well documented as part of DO Spaces.
https://www.digitalocean.com/community/questions/mount-point-with-spaces
There are some issues with making new files public readable. Here is a discussion. Once you have made your files public these are visible to the world via your static site. So the issue with DO Spaces that you may need to make them public manually so that these are visible to the world is out of the scope of mounting it locally and copying files.
Once these image files are copied to the DO spaces, then these are served just fine. You can configure Prestashop to use a CDN under Advanced Settings. Point to static.mywebsite.com in prestashop configuration. Prestashop will server images from the CDN.
Prestashop has no function to sync/copy images to a remote destination, the images will always be uploaded to the filesystem where it is installed.
"Media server" function in the back office only tells Prestashop the web path from which the images have to be retrieved, so it is your CDN service that have to handle the image "pickup and copy" from the backend server, so first make sure your CDN service can work like that and it is not a different object storage service where you have to manually upload resources.
Then, you have to make sure that CDN is correctly configured to point correctly to your backend so that the first web query reads the image from the server and the subsequent ones from the CDN.
Being aware of that, a typical approach is to create a subdomain like "static.mywebsite.com" with a CNAME to your CDN "https://xxxxxxxx.fra1.cdn.digitaloceanspaces.com" , then you can enter "static.mywebsite.com" in the media server space of Prestashop backoffice.

HTACCESS ignores images

I have the following very simple htaccess file:
RewriteEngine On
RewriteRule a.jpg b.jpg
RewriteRule c.php d.php
All four resources are in the root folder.
The PHP rule works as expected, however, the JPG rule is just ignored as if it were not there. The image a.jpg continues to display.
I am completely clueless on why that would happen.
The only explanation I could think of is that Apache is somehow configured not to INVOKE htaccess at all if the requested resource is an image. Is that even possible?
I found out the reason and I am posting my answer in case anyone faces the same issue.
It appears that both Nginx and Apache are configured on the server. Nginx is internet facing and Apache is internal.
It appears that the web hosting company has done so to benefit from Nginx's better performance and to provide compatibility to anyone coming from Apache environment at the same time.
When Nginx receives a PHP request from the internet it allows the request to pass through and reach Apache but when the resource is a static resource (image, css, js) Nginx delivers the resource itself for optimum performance.
The htaccess image rule above is not processed because the request is not even reaching Apache.
I temporarily solved the problem by not allowing Nginx to handle the images itself and allowing them to proceed to Apache.
The better solution of course is to remove htaccess dependency and handle everything within Nginx configuration file, which I will be doing soon.
The best solution of course is to remove Apache completely but it is a shared server and I don't have full control.

nginx conf express and assets returning 404

Have been at this all day and so far not getting to where I'd a liked to have been.
Running pretty much the latest version of everything as just building a new server to move off IIS/IISNode.
I have nginx installed and some conf going that serves only my main index file from a sub dir of /vra/www/. However it does not load any assets or sub-dir pages.
If I call the assets directly, using lowercase URL it returns 404 but uppercase URLs where needed work fine.
My conf example can be seen here: pastebin.com/a12TqP6w
What all think in the webroot folder. I think it has only one directory html your codes are put in the html directory there is no stuff in the mentioned directory /var/www/dev.fishpal.com. change your configuration accordingly where is web content is placed.
Replace with this one.
root /var/www/dev.fishpal.com/html;
or put your codes and stuff in the following directory.
root /var/www/dev.fishpal.com;
Needed to drop some extra things I had inside my conf file

Expressjs static space in file name trailing slash

I use express to serve static files on local disk.
app.use('/media/', express.static(path.join(__dirname, 'media'), {redirect: false}))
And under media folder, I have a folder named image files. In that folder, I have a file called image.png.
When I use http://localhost:3000/media/image%20files/image.png in the address field of my browser, express always redirect the request to http://localhost:3000/media/image%20files/image.png/ that adding a trailing slash.
If I remove the space in the folder name, it serves the image file.
What I did wrong? Is this a bug?
Thanks,
To answer my own question so if anyone runs into the same issue they have a possible answer.
I cleared Chrome cache and the problem is gone.

.htaccess works on Apache server, but not on FTP directory

I recently found the use of a .htaccess file to edit the URL of my webpages. This is done with mod_rewrite (Apache). I use XAMPP and the working files are inside of the appropriate htdocs folder. While in the local directory, the .htaccess file does the job and it edits the URL. I have a domain name that I've been working on and periodically update the working files to that. When I upload these files to the domain through FTP, the .htaccess file doesn't work correctly, as you can imagine since Apache modules have no way of working on a web directory. So my question is, how do I make a .htaccess file work in a web directory without Apache's mod_rewrite module?
Your question is not sufficiently clear. URL rewriting won't work if you're just accessing the static files (i.e. file:///home/user/www/index.html) rather than going through the Apache server (http://localhost/~user/index.html) since Apache will never process the request.
Perhaps your .htaccess file is not being uploaded properly? Some programs will complain a bit when you try to upload strangely named files, such as those beginning with a period.