Hi. Searched around the forums and tried similar posts but did not work. I upload several drupal sites into subdirectories to a shared hosting server ( @ network solutions) to serve as demo sites for clients. One of the drupal sites, my own personal website, also resides in one of these subdirectories. I wish to have my domain transparently resolve to this folder. I have set up the .htaccess file in my root directory like this...

RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
RewriteCond %{REQUEST_URI} !^/mysitedirectory/
RewriteRule (.*) /mysitedirectory/$1 

When i visit www.mydomain.com, my personal site displays as it should. However, when I click on any link, the url displays in the format www.mydomain.com/mysitedirectory/"page" instead of just www.mydomain.com/"page". Clicking on this usually either throws server errors or clicks back to the front page of the site.

PS. I tried setting the base_url in settings.php to "www.mydomain.com", but this threw errors when I visited the domain.

Thanks in advance.

Comments

latte’s picture

subscribing...

bsenftner’s picture

Have you read through this: http://drupal.org/node/520700 ?

Your situation looks very similar to what I went through, described by that link above.

sakins’s picture

I followed the tutorial and now I get a "page not found" error when accessing www.mydomain.com. There are no styles and no links available. I tried different combinations of modifiying the 3 files (.htaccess in root, .htaccess in drupal folder, and settings.php) but all combinations recieved some sort of server error.

sakins’s picture

After hours of confusion, I finally found a configuration that works for Network Solutions and redirecting a domain to a drupal subfolder using .htaccess in root folder, .htaccess in Drupal folder, and settings.php.

This is the doc root .htaccess file..

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
RewriteCond %{REQUEST_URI} !^/drupal/
RewriteRule (.*) /drupal/$1 

I left the /drupal .htaccess file alone, besides uncommenting and modifying the following line.

RewriteBase /drupal

In settings.php, I uncommented the base_url and changed to..

 $base_url = 'http://www.mydomain.com';  // NO trailing slash!

What a learning experience! Thank you for your help.

Doudi’s picture

Your drupal installation is located in http://www.mydomain.com/drupal
And http://www.mydomain.com will act as if the subfolder is the root of that domain.

Will it still be possible to access the site by using the original url of the installation (http://www.mydomain.com/drupal)?
Did they become clones? Or is http://www.mydomain.com/drupal replaced by the domain url?

ntigh52’s picture

Thanks,
you help me a lot!!!!
I solve the problem!
:-)

shanarigelhaupt’s picture

I tried this, but it wiped out my CSS. I am working in Drupal 7 though. Any thoughts?

ntigh52’s picture

You are right,
I had problem aslo,
I solve that like that.

Create a new .htaccess file and place it in the web root with the following code:
( replace "drupal7" to your subfolder name )

Options -Indexes
Options +FollowSymLinks 
RewriteEngine on

# Redirect all user to without WWW
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]

# Serve Drupal 7 from sub directory in web root
RewriteRule ^$ drupal7/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/drupal7%{REQUEST_URI} -f
RewriteRule .* drupal7/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* drupal7/index.php?q=$0 [QSA]

Now you need to change 1 more line in sites/default/settings.php.
Look for the $base_path variable, uncomment it and change the value to your domain.

$base_url = 'http://yourdomain.com';  // NO trailing slash!

You're now done!
I am not a Genius I found that here: http://kahthong.com/node/74
Good luck

jhr’s picture

This worked on godaddy....

mattbk’s picture

tanzeel’s picture

Perfect. Thank you :)

Thank you,
Tanzeel