Last updated October 5, 2012. Created on October 5, 2012.
Edited by no_longer_active_13. Log in to edit this page.

This write up needs (technical) review. Don't just copy and paste this code unless you have at least some understanding of the matter.

In Drupal 7 in order to run https(SSL) for the admin backend and run a normal http on the front I had to do the following. This code is intented for if the backend is running on a subdomain/ subdirectory on SSL with a different URL address then the http address of the front end, and with clean URLs enabled.

In settings.php:

if ($_SERVER['SERVER_PORT'] == 443) {
$base_url = 'https://address_1.com/subdirectory';
} else {
$base_url = 'http://subdomain.address_2.com';
}

The first $base_url is the one where you have your admin backend. The second is for your website front end. What this does is when you type the address check whether we are on a https or a http connection. Then the if the address match the $base_url either become a https or a http connection and go to the $base_url that is set.

Now this will work fine as is without the Clean URL enabled. However when you enable Clean URL it stops working. The reason is that we have to set the rewritebase, but where do we set the rewritebase to? If we set it to the subdirectory for the back end then the front end URLs error out. If we set it to the front end then the back end URLs error out. If we leave it as is the front end will work, but the backend won't work. According to the Drupal Docs this can be solved as follows:

In the Drupal .htaccess in your subdirectory where you have Drupal installed replace:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]

With:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/subdirectory/(.*)$
RewriteRule ^(.*)$ /subdirectory/index.php?q=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]

The order of the rules is important. If you turn them around it won't work.

You should now be able to access the https(SSL) side for your back end and the http side for the front end of the website with clean URLs.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.