R
R
rinaz222020-06-23 18:26:02
PHP
rinaz22, 2020-06-23 18:26:02

Is it possible to upload files through another domain without changing the paths in html?

Hello. You need to change the path for loading images and styles to a subdomain. The page itself is loaded on the main domain. Is it possible to somehow change the download path without changing the path in the code itself (I do not prescribe the path to the subdomain). Where does the browser get the website domain from? Is it possible to somehow change this using PHP and HTACCESS?
Maybe the question is stupid, but still ...)
PS: <base>not suitable

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tendor, 2020-06-23
@Tendor

Of course you can, it all depends on the upload method, but you are probably uploading through a form. Therefore, in the form you need to specify the path where to send the request. Specify in the form <form action="https://example.com"></form>

A
Arseny, 2020-06-23
Matytsyn @ArsenyMatytsyn

Yes, you can make redirects at the Apache (htaccess) level, but better on nginx.
I’ll say more, this is a somewhat popular question of how to straighten out static data (assets) from the necessary directory from such a state (redirect) (a case from the nature of hosting, not VDS-ok and others).
PS: in the end, though, I would still recommend keeping statics in the project, if it's not a CDN, at least it's convenient.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question