docker4drupal icon indicating copy to clipboard operation
docker4drupal copied to clipboard

Running Drupal from a subfolder (URL to have this subfolder)

Open igorbiki opened this issue 10 months ago • 1 comments

Context Everything works as expected when Drupal is installed in /var/www/html. In this case base_path is "/". Which works.

What I want to do is, if I can make Drupal run from a subfolder of the root, so my URL is "docker.drupal.localhost:8000/mysub"

Tried modifying NGINX_SERVER_ROOT to point to "/var/www/html/mysub/web" but URL looks clean, no subfolder in the URL.

Next, I tried to send NGINX_SERVER_EXTRA_CONF_FILEPATH file with locations configuration (that failed due to my limited knowledge of how to configure nginx). The initial plan was simple, copy all the rules for location / and make it /mysub. Maybe I messed up rewrite rules (if ones are needed at all).

Then, I tried to modify traefik rules for nginx, using Path (and PathPrefix) instead of Host, but that failed as well.

Why would you need something like that?! If base_path is not "/" in some cases links come prefixed with this base_path (happens on popular Drupal hosting platforms, not to name one here). And as a result, some links are broken.

igorbiki avatar Feb 18 '25 17:02 igorbiki

I have the same problem.

I have tried to deploy Drupal 10 and 11 from a subpath and it is impossible. I have tried to modify Traefik, Apache and Drupal.

I have used PathPrefix, PathPrefix and StripPrefix. Is there any configuration for the container that allows this?

nonodev96 avatar Apr 13 '25 09:04 nonodev96