Q:

Magento 2.2: Base URL removed when attempting to access admin login

Was having problems yesterday with my server, which the community seemed to think were irreparable, so I decided to rebuild it.
Set up a LAMP stack with Redis and re-installed magento. Used my existing database, imported images from the old server and everything was working fine, after a little troubleshooting.
My Redis installation was only being used for session storage, because magento's documentation doesn't make it clear whether a password can be used with redis for other types of storage. I managed to find a walkthrough which gives an example of the env.php file, including passwords for redis default and full page cache. I applied this solution and it appeared to be working last night, but when I attempted to access the admin panel this morning I faced an error.
The public folder of my server is a symlink to [magento_install_dir]/pub.
The base URL is set as follows: http://mywebsite.com/.
Media URL is: {{base_url}}media/.
Static URL is: {{base_url}}static/.
Backend frontname is: admin
For some reason, when I type http://mywebsite.com/admininto the address bar and push enter, I am redirected to the url http://index.php/admin/http:/index/index/index.php/admin/admin/index/index/key/03d43f5c1cec52b7033fd3be4383c7b908e3cf223f94f70edc6c1a3ba682d11f/%3FSID%3D5jmbrv35q7tt5e8kostgr8ijjr/key/4f38776e3016c76ef23af1805de97c2ebf5380684631e4ae24a4506ada844975/?SID=5jmbrv35q7tt5e8kostgr8ijjr
So, for some reason, the base URL either isn't being added, or is being interpreted as /index.php. Also, the second repetition of the url includes two instances of admin/, which makes me think that maybe the backend frontname that I have defined is being appended with the default. I could perhaps troubleshoot this issue, but I can't work out why the URL is not prepended with the site's base URL.

A:

I had a similar issue when setting up a docker.
The following command resolved the issue:

Ubuntu server

chown -R :www-data /[path]/[to]/[magento]/[root]/[folder]

CentOS server

chown -R :apache /[path]/[to]/[magento]/[root]/[folder]

Afterwards, I cleared Magento's cache and flushed Redis. 
Hope this helps!

