2

My web host directs traffic to the main public_html folder on the site for my main site. `

However, I want my main site to redirect to a subfolder for organizational reasons, so I can easily manage just the main site files within that folder. Therefore I want to redirect to public_html\mysite.com

I have created a .htaccess in the public_html folder that DOES redirect properly when I just point it to a test index.html file. However, when I try to point to index.php of for my drupal installation, I get the following :

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@mysite.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Here is my .htaccess which lives in the public_html

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?<mysite>.com$
RewriteCond %{REQUEST_URI} !^/<mysite>.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /<mysite>.com/$1
RewriteCond %{HTTP_HOST} ^(www.)?<mysite>.com$
RewriteRule ^(/)?$ <mysite>.com/production/dev-code/index.php [L]

Do I need to modify the .htaccess in \public_html\mysite.com` somehow for drupal to load? I don't have access to the server error log.

2

Just add a rewriteBase to your .htaccess file

RewriteBase /subdirectory

Note that this goes into the .htaccess file in the “subdirectory”, not your website root .htaccess file!

0

I ultimately did not have to use RewriteBase. I changed the .htaccess in public_html and change the $base_url in my settings.php

My setup was such that I needed to redirect to a subdirectory(yourdomain.com) within a subdirectory(subdirectory) from the main public_html folder. This is because for organizational purposes, I wanted everything to live under subdirectories. So the drupal installation was at public_html\mydomain.com\subdirectory

I modified the .htaccess at the public_html level to redirect to the subdirectory where drupal was installed.

yourdomain.com=the directory where you want your site to redirect to instead of the main public_htmlfolder.

subdirectory = If you have an additional subdirectory structure to where your drupal installation goes. I did this so that the drupal install would not live directly under the yourdomain.com because I wanted to keep my private directory there.

RewriteRule ^$ yourdomain.com/subdirectory/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/yourdomain.com/subdirectory%{REQUEST_URI} -f
RewriteRule .* yourdomain.com/subdirectory/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* yourdomain.com/subdirectory/index.php?q=$0 [QSA]

The RewriteCond %{DOCUMENT_ROOT}/yourdomain.com/subdirectory%{REQUEST_URI} -f and corresponding rule were necessary because otherwise when you start clicking on links in your site, it will show http://yourdomain.com/subdirectory

Finally, you need to change the $base_url in settings.php to http://yourdomain.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.