简体   繁体   中英

Drupal redirect to web folder

I'm trying to configure redirects on a drupal site using apache web server. I'm trying to implement this https://www.symphonythemes.com/drupal-blog/remove-web-part-composer-based-drupal-site but I cannot seem to get it working. I have several drupal sites running in /var/www/html/drupal . My drupal configuration in my httpd.conf files are

- name: create drupal httpd conf
    copy:
      content: |
               <VirtualHost *:80>
                 ServerName qsd
                 DocumentRoot /var/www/html/drupal
                 <Directory />
                    Options FollowSymlinks
                    AllowOverride All
                 </Directory>
               </VirtualHost>
      dest: /etc/httpd/conf.d/drupal.conf

and

- name: allow override /var/www/html
    copy:
      content: |
                <Directory "/var/www/html">
                  Options Indexes FollowSymLinks
                  AllowOverride All
                  Require all granted
                </Directory>
      dest: /etc/httpd/conf.d/app.conf

I've added

if ( isset($GLOBALS['request']) && '/web/index.php' === $GLOBALS['request']->server->get('SCRIPT_NAME') ) {
    $GLOBALS['request']->server->set('SCRIPT_NAME', '/index.php');
}

to my settings.php.

Now I'm trying to get my .htaccess files correct for my drupal app which is in /var/www/html/drupal/app . In /var/www/html/drupal/app/.htaccess I have

<IfModule mod_rewrite.c>
RewriteEngine on
# Redirect to the subdirectory because that's where Drupal is installed
RewriteBase /app
RewriteRule (.*) web/$1 [L]
</IfModule>

In var/www/html/drupal/app/web/.htaccess I have

RewriteBase /web

When I visit https://example.com/app I get redirected to my OIDC provider but the redirect_uri is missing the /app . And when I visit https://example.com/app/user/login I get a 404, but prior to adding .htaccess https://example.com/app/web/user/login was working. Any help would be much appreciated, thank you.

I needed to change var/www/html/drupal/app/web/.htaccess to

RewriteBase /app/web

and settings.php to

if ( isset($GLOBALS['request']) && '/app/web/index.php' === $GLOBALS['request']->server->get('SCRIPT_NAME') ) {
    $GLOBALS['request']->server->set('SCRIPT_NAME', '/app/index.php');
}

But I think creating a virtual host for each site would allow the original configuration to work as @2pha suggested

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM