-5

I have a Drupal 8 site installed in a root directory(/var/www/html). I then installed another Drupal 8 site in another folder(/var/www/html/myFolder).

The homepage is working fine. If I try to log in, the first Drupal 8 server returns a 404 error.

Is there is any way to solve this issue?

1
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Clive
    Commented May 18, 2018 at 13:54

3 Answers 3

3

Check both site's .htaccess files and find the lines where it says RewriteBase etc.

Your first site's .htaccess needs:

  # If your site is running in a VirtualDocumentRoot at http://example.com/,
  # uncomment the following line:
  RewriteBase /

And your seconds site's .htaccess needs:

  # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at http://example.com/drupal uncomment and
  # modify the following line:
  RewriteBase /myFolder

Apart from that your vhost file should have the following directives included.

<VirtualHost *:80>
    ServerName www.example.com
    ServerAlias example.com *.example.com

    ServerAdmin [email protected]
    DocumentRoot /var/www/html

    <Directory /var/www/html>
        Options -Indexes
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog /var/log/apache2/example_com_error.log
    LogLevel warn
    CustomLog /var/log/apache2/example_com_access.log combined
</VirtualHost>
5
  • Sorry, Not working. I changed the RewriteBase on both .htaccess. Commented May 15, 2018 at 8:46
  • I tried before as per the article. I created two separate .conf file for two sites and enabled then restarted apache. That was not working. Then I deleted that. Commented May 15, 2018 at 8:52
  • I could share my apache default.conf file here Commented May 15, 2018 at 8:53
  • I will delete everything from default.conf page and put above code. Then I will let you. whether its works or not. Commented May 15, 2018 at 8:58
  • 1
    @SarathKumar - You only need one Apache conf as long as you don't want to access the second site from a different domain. And please use both Drupal's default .htaccess files.
    – leymannx
    Commented May 20, 2018 at 15:06
2

First of all: You might want to check the logs: both sites logs + server logs + db logs. There got to be some error code somewhere.

Here's a list of things you can try:

  • Use different admin users for both sites
  • Check the redirect rules in your htaccess. Especially the www redirect, maybe there is something wrong in your declaration that can confuse the redirection
  • Make sure the 2 sites have clearly 2 differents domain declaration in your vhost, and that both declarations are pointing to the right folder
  • Make sure your directory declaration for each site contains the full path (<Directory /var/www/html/site1>), here is an example:
    <Directory /var/www/html/site1> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>

  • Make also sure you have nicely declared your bind zone (zone declaration in named.conf.local and creation of your db.domain.com). If one of them is a subdomain, hopefully you should have made a subdomain declaration in the main domain.

  • And check again your settings, especially the base_url and trusted host patterns, that can help too.

For each drupal change, clear the caches of the site that was edited, and eventually the second just for peace of mind. For every change made on the web server configuration (vhost), restart it (apache2/nginx). For each change in your bind zone, restart the bind service, and the webserver for peace of mind.

As you can see there might be quite a few sources to your issue. You may want to make more comparing tests of use cases what happens to one site if I trigger this in the second and vice versa. Hope this can help.

2
+25

As said previously, check your HTACCESS on both sites, and your apache virtual host. In theory, you can imbricate websites... But it's not recommended and not easily maintainable.

But the simpler and far more recommended way will be to reorganise your sites/folders : If you want to keep 2 Drupal separately :

  • /var/www/html/SiteNAME1
  • /var/www/html/SiteNAME2

If you are interested in multi site architecture, please check https://www.drupal.org/docs/8/multisite

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.