0

I have a site using Drupal 8.5 I installed with Composer.
When users want to visit the site, they'd normally need to add /web after the domain to access it. I have a cpanel redirect that redirects users from domain abc.com to abc.com/web, so they don't have to add /web.
This solution is still a bit silly because the visitors still see the abc.com/web while I really want it to look like a regular website domain, domain.com.

I'm not allowed to use virtual hosts, but I am allowed to use htacces or symlinks. How do I "redirect" visitors from domain localhost/temp-project to localhost/temp-project/web/index.php without having /web in the URL?

--Update 2-- I've tried to add a .htaccess snippet (from GitHub) in my root (localhost/temp-project) to point to /web and browsed to localhost/temp-project:

#Redirect to www location with subdirectory
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} localhost/temp-project [NC]
RewriteRule ^(.*)$ /web/index.php[R=301,NC]

This just doesn't do anything, what's going wrong here?

2

You should have your host point directly to the "web" directory instead of your project root. I've run into this issue on webfaction hosting and my solution (actually my co-worker's) was to have 2 "apps." The first app is not web accessible and this is where my drupal-composer/drupal-project's root is. Then I create a second app that is web accessible, e.g. domain.com and is a symlink to the first apps /web directory. Maybe you can use this same approach.

  • Hi Sonfd, what do you mean exactly with the term "app"? – Ducky Apr 21 '18 at 21:56
  • I'm not sure what would be the equivalent on your hosting provider. But basically on webfaction an app could be a directory where you placed static html, or a php app, or a python app, or a symlink, etc. Maybe try the solution [here] (drupal.stackexchange.com/questions/241761/…). – sonfd Apr 21 '18 at 22:07
0

If you can't change the project root, then I'd suggest either doing a Rewrite directive within .htaccess or just making an alias on Drupal (or setting the homepage to be /web).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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