What happened ?#
(how did my drupal have this web
folder)
I sometimes install drupal via the composer
command as suggested in the official install method, as shown below:

And as a result I get a file hierachy alike the following:
1
2
3
4
5
6
7
8
9
10
11
| /public_html $ ls -al
drwxr-xr-x 6 u236049598 o1006024984 4096 Jun 5 04:17 .
drwxr-xr-x 4 u236049598 o1006024984 4096 Jun 5 03:50 ..
-rw-r--r-- 1 u236049598 o1006024984 3938 Jun 5 04:06 composer.json
-rw-r--r-- 1 u236049598 o1006024984 269988 Jun 5 04:06 composer.lock
-rw-r--r-- 1 u236049598 o1006024984 135 Jun 5 04:06 .cursorignore
-rw-r--r-- 1 u236049598 o1006024984 357 Jun 5 04:06 .editorconfig
-rw-r--r-- 1 u236049598 o1006024984 4222 Jun 5 04:06 .gitattributes
-rw-r--r-- 1 u236049598 o1006024984 230 Jun 5 04:11 .htaccess
drwxr-xr-x 28 u236049598 o1006024984 4096 Jun 5 04:06 vendor
drwxr-xr-x 7 u236049598 o1006024984 4096 Jun 5 04:06 web
|
(*Whilst if you would download it via the zip
or tar
option, you have something like this: screenshot)
Fix Step-1: Apache .htaccess#
(to redirect the home
directory to the web
folder)
Create the .htaccess
file in your root public_html
directory with the following content:
1
2
3
4
5
| RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteCond %{REQUEST_URI} !subdirectory_path/
RewriteRule (.*) /subdirectory_path/$1 [L]
|
Replace example.com
with your domain name and subdirectory_path
with the name of the folder where your website’s files are located (in our case it is web
).
For instance if my domain is drupal-radix-boostrap-example.simon-hu.com
, then I’ll need to have the following in my .htaccess
file
1
2
3
4
5
| RewriteEngine on
RewriteCond %{HTTP_HOST} ^drupal-radix-boostrap-example.simon-hu.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.drupal-radix-boostrap-example.simon-hu.com$
RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) /web/$1 [L]
|
Fix Step-2: File Permission#
(to make sure all the css
and js
files loads properly)
If you happen to be zipping a whole drupal folder you are developing on your local, thowing them onto the server, some of your files may have permission issues. For instance, when doing the aforementioned, my css/javascript in the sub-theme happen to have the following file permission:
1
2
3
4
5
6
7
8
| subtheme/build $ ls -al
total 676
drwxr-xr-x 2 u236049598 o1006024984 4096 Jun 5 04:17 .
drwxr-xr-x 4 u236049598 o1006024984 4096 Jun 5 04:17 ..
-rw-r----- 1 u236049598 o1006024984 347745 Jun 5 04:17 main.script.js
-rw-r----- 1 u236049598 o1006024984 311595 Jun 5 04:17 main.script.js.map
-rw-r----- 1 u236049598 o1006024984 347745 Jun 5 04:17 styke.css
-rw-r----- 1 u236049598 o1006024984 311595 Jun 5 04:17 style.css.map
|
And you will see your website load without styles:

The quick fix is to change all your file’s permission recursively via chmod -R 755 web
:

But you might wanna change some of the files’ permissions, for instance:
1
2
3
| chmod 555 ./sites/default/settings.php
chmod 555 ./sites/default
chmod 555 ./.htaccess
|
Reference#