0

Built a website on localhost, moved it to shared-hosting where webroot is htdocs but when visiting the website through the hosting's given IP address it obviously doesn't load the website, because the index.php is inside htdocs/web/?

This is very limited shared-hosting, no control panel and no way to edit apache's configs, only .htacess files accessible in htdocs.

Current attempts:

a. Homepage loads fine, but /web/ is added in the URL in the address bar for every sub-page.

RewriteEngine On
RewriteRule ^(.*)$ /web/$1 [L]

b. Homepage loads and no /web/ is added for any links in e.g. main menu navigation while from homepage and clicking them even loads the page without /web/ added to the URL, but the /web/ is added back to the menu once you're within any subpage.

 RewriteRule ^(.*)$ web/$1 [L,NC]

Menu links from homepage enter image description here

Same menu links from within subpages enter image description here

Interesting find, while you can visit content pages from menu links, you cannot access e.g. /user when trying to login, you get WSOD Redirects to external URLs are not allowed by default, use \Drupal\Core\Routing\TrustedRedirectResponse for it. You have to enter web/user in order to login.

update: Similar issue described here https://www.drupal.org/forum/support/installing-drupal/2022-02-21/redirects-to-external-urls-are-not-allowed-by-default-use-drupalcoreroutingtrustedredirectresponse#comment-14996104 but no actual solution, only the mention of the redirection to /web/? How to redirect properly without /web/ showing in URL adress bar?

1 Answer 1

3

This is very limited shared-hosting, no control panel and no way to edit apache's configs, only .htacess files accessible in htdocs

Look for a new hosting company, until then you can use the legacy composer project:

composer create-project drupal/legacy-project my_site_name_dir

and then require all the components you had before.

Instead of install.php for a new database, you can put a copy of the existing database and sites/default/files directory in the fresh composer project and clear the cache. If this produces errors, check that you have exactly the same versions of all modules.

4
  • Any links with more in-depth steps for migrating from recommended to legacy? Especially for last paragraph? Commented Sep 6, 2023 at 15:25
  • You'll see in the new composer project what is missing from the existing site. Just try it. Always copy the database and the files so that if it doesn't work you can delete the new project directory and start over.
    – 4uk4
    Commented Sep 6, 2023 at 15:51
  • This is the right answer and solved the problem. Also do not forget to copy themes and libraries directories. You do not need to run install.php, only copy the database and copy/paste required modules in the composer.json Commented Sep 8, 2023 at 12:54
  • For themes and libraries not managed by Composer. Compare both site directories in Midnight Commander and copy missing files or folders from left to right. And yes, that's important to mention not to run install.php, I add this to the answer.
    – 4uk4
    Commented Sep 8, 2023 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.