Hi.
I had to migrate my site to a new server/hosting service (tophost). I set up a subdomain by adding a CNAME record ("blog" on "mysite.ext"), and - as suggested by the registar, I added a .htaccess in the webroot (/htdocs):

RewriteEngine On
RewriteBase / 
#RewriteCond %{HTTP_HOST} blog.mysite.ext
#RewriteCond %{REQUEST_URI} !blog/
#RewriteRule ^(.*)$ /blog/$1 [L]

(* instructions by registar reported tht subdomains have to be handled via .htaccess)
I then uploaded my drupal blog in "blog" subfolder, but I got a 500 server error, alongside other minor problems.

So I had two different .htaccess:
1) [in root, so /htdocs]

RewriteEngine On
RewriteBase / 

RewriteCond %{HTTP_HOST} ^mysite\.ext$ [NC]
RewriteRule ^(.*)$ http://www.mysite.ext/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^blog.mysite.ext$
RewriteRule ^(.*)$ http://www.mysite.ext/blog/$1 [R=301,L]

2) [in drupal folder, so /htdocs/blog] I just kept the .htaccess from local installation, but I uncommented the rewrite base url line and noted /blog

But it doesn't work: I can access the static site in /htdocs, but when I try and reach the drupal site (/htdocs/blog), by typing blog.mysite.ext or www.mysite.ext/blog, I just keep gettin' some 500 server error (it says some missing or uncorrect .htaccess file)

Now, my goal is to have
-a main (static) site stored in the root, accessible by typing either www.mysite.ext or just mysite.ext
-a drupal site in the /blog subfolder/subdomain, accessible by blog.mysite.ext and -less important - mysite.ext/blog (and other pages accordingly, e.g. blog.mysite.ext/page or mysite.ext/blog/page).

In order to get this, should I have two different .htaccess or just one? And where I went wrong?
Thank you!

Comments

Kristi Wachter’s picture

Hi desmoblu,

This sounds tricky.

I guess one thing I would check is whether your site is set up to handle the index.php as the main index file for the subdirectory. One way to test this might be to temporarily rename the index.php inside your blog directory to something else (like z-index.txt) and create a new index.php file that just returns some simple HTML. If that works, that's an indicator that the index.php file SHOULD be handling requests to the Drupal site, and you can delete your temporary index.php file and restore the Drupal one. You can also test accessing a static html file within the blog folder - if you create a simple file called blogtest.html within the blog directory, can you access that?

If it were me, I might consider switching to a different hosting provider that makes this easier. For many people, using a cPanel setup works really well and is easy to configure. I've done exactly what you're doing here - running Drupal in a subdirectory of a static site - on hosting with a cPanel, and it was quick and easy to set up.

I hope this helps a little with the troubleshooting. It would be great if your hosting provider could help you further, too.

Good luck,

Kristi

˚ ˚ ˚ ˚ ˚
Kristi Wachter
Drupal consultant, evangelist, and enthusiast