How to remove /drupal from URL in Drupal 7 when installation is in the associated sub-directory

前端 未结 3 1564
感动是毒
感动是毒 2021-02-10 18:47

In Drupal 6 I was able to successful install Drupal in a subdirectory called drupal and then reference the site without having to use example.com/drupal. In Drupal 6 to get this

相关标签:
3条回答
  • 2021-02-10 19:27

    On Apache server, add this to the root .htaccess file.

    RewriteEngine on RewriteRule (.*) drupal/$1 [L]

    Update the drupal settings.php file (in /drupal/site/default/ directory) so that the $base_url line reads:

    $base_url = 'http://www.example.com';
    
    0 讨论(0)
  • 2021-02-10 19:37

    Try with this :

    RewriteEngine On
    
    RewriteBase /example.com
    RewriteRule ^$ drupal/ [L]
    
    # rewrite rules for drupal files
    RewriteCond %{DOCUMENT_ROOT}/example.com/drupal/$1 -f
    RewriteRule ^(.*)$ drupal/$1 [L,QSA]
    
    # rewrite rules for drupal paths
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ drupal/index.php?q=$1 [L,QSA]
    

    Put this .htaccess file in example.com directory. You don't have to modify drupal7 .htaccess

    0 讨论(0)
  • 2021-02-10 19:39

    I answered a very similar question on this here: Two Drupal installation on the same server My answer to your question is the same, I recommend eschewing the rewrite method in favor of the virtual host method as described below (which is just an excerpt of what I answered in the link above):

    ... To do this correctly you must first enter the following line (or un-comment the line if >it already exists):

    NameVirtualHost *:80
    

    Next you must create the two virtual host entries. One will be similar to the following:

    <VirtualHost *:80>
    ServerName your.url.fortheroot
    ServerAlias alternate.url.fortheroot
    DocumentRoot "/path/to/webroot"
    </VirtualHost>
    

    The next entry would be similar to the following

    <VirtualHost *:80>
    ServerName your.url.forthesubfoldertest
    ServerAlias alternate.url.forthesubfolder
    DocumentRoot "/path/to/webroot/test"
    </VirtualHost>
    

    ...

    In your case, however, you would only require one virtual host entry & not two.

    Additionally, it should be noted that, should you desire to serve a site from a location NOT in your webroot then you would also need a

    <Directory></Directory>
    

    entry to tell Apache what access to give to visitors (NOTE: in Linux the Apache user should be made owner of the files [or permissions should be set in a method that still allows the apache user rights to serve the files if you want to avoid giving it ownership])

    0 讨论(0)
提交回复
热议问题