-1

I've got D8 installed in a subdirectory example.com/drupal, but I don't want "drupal" to appear in any of the URLs. I've added the following to my example.com/.htaccess file:

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

This successfully allows my site visitors to browse to example.com, but any further interaction with the site (e.g. browsing to a node, searching for "foo", etc.) causes "drupal" to appear in the URL.

What do I need to completely mask "drupal" from all site URLs?

1 Answer 1

0

Check this other question out, How do I change the base URL?
and this issue on drupal.org, https://www.drupal.org/node/2753591

In summary, Drupal 8 as of right now detects where it is automatically. On D7 there used to be a base_url option which could be used for this.

In Drupal 8 this option has been removed. You don't have to configure base_url to run your site. Drupal 8 can detect this without your help. If not, you should first check your webserver configuration.


.htaccess approach – You can't do this using the .htaccess. You'll end up with a redirect from drupal/ going to / which will then request /drupal and go back to / and so forth. You'll end up with a redirect loop.

If you want to test it, add this to Drupal's .htaccess (/drupal/.htaccess):

RewriteCond %{REQUEST_URI} ^(/drupal)(/)(.*)
RewriteRule ^ %2%3 [L,R=301]

Options I see,

  1. Move the files from the drupal directory one directory up
  2. Point the virtualhost to the drupal directory.
    A lot of people use docroot or htdocs for a similar setup. This allows for some files to be in the repo but outside the directory being served by the web server.
  3. Try out the patch from the second link. It needs to be community reviewed for acceptance, so that would actually be great.

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.