Hi,

We have 5 sites now installed in the Multisite install. All seems well apart from the or Wordpress blog. This is installed in the root directory and seems to be the only way to get this to work for www.oursite.com/blog/

However, the blog is duplicated accross all the other domains on the multi-site install www.myothersire/blog/

Not good as this blog is now accessible on sites where it should not be and Google will eventually pick up in the duplication.

I have installed the robots.txt module and I have restricted the /blog/ from being indexed on domains it should not show up but this is somewhat of a poor solution.

Does anyone have any idea how to solve this? Also, is it possible to have a specific htaccess for each domain in a multi-site environment?

Thanks for any help,

dutchie

Comments

justageek’s picture

Why not just use Drupal for the blog on the one site that needs a blog.

dutchie76’s picture

Because I prefer the current version of Wordpress to that of Drupal's blog. I have read that many other have this sort of issue and despite digging deep into Drupals archives I cannot see that anyone has found a solution to this.

justageek’s picture

There is more than one way to set up a multi-site installation. Can you briefly describer your file structure and rewrite rules for me?

I think what you need is definitely doable with apache rules.

Also, in your hosting environment can you edit your core httpd.conf file for apache?

frames’s picture

You don't say how it all is installed. Where is WordPress? If you have Apache you could have your directories setup like this:

drupal/ (with all the multi-sites inside)
wordpress/ (with only wordpress)

In the Apache virtual host that you want the blog to be using WP, you could use the Alias directive in mod.alias or something like that.

The other thing I can think of is defining a subdomain for wordpress in a different Apache virtual dir (i.e. http://blog.oursite.com/) pointed to a separate wordpress dir, but that's not what you want.

frames’s picture

I have "hacked" a Drupal and a WP test setups of mine here and it works ... partially.

I did what I stated below, and in WP "WordPress address" and "blog address" (General options) I entered http://oursite.com/blog.

All the admin stuff works out of the box. The content is "canibalized" by Drupal.

All I had to do for everything to work was to update the Rewrite rules in WP. I went to the permalinks options and got this:


RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

Which only differs in those two highlighted lines (obvious).

Modified my .htaccess in WP and voilà!

Hope that helps.

PS: My Drupal site is not multisite setup (I only have a site) but this main site is setup as such, so I don't see how this would not work for you.

frames’s picture

"Also, is it possible to have a specific htaccess for each domain in a multi-site environment?"

I have not found anything on Google about this for Drupal, but I figured out a way (again with Apache). Have not tried it, but I would imagine this would work:

http://httpd.apache.org/docs/1.3/howto/htaccess.html

If you want to call your .htaccess file something else, you can change the name of the file using the AccessFileName directive.

So put "AccessFileName .htaccess_oursite_com" in your Apache virtual config for oursite.com and add .htaccess_oursite_com in your base Drupal directory and that would pick it up. Do the same with .htaccess_myothersite_com (and the others) and you should have it.

Shouldn't it?

However, for your original question, you shouldn't need this.

frames’s picture

Sorry, double posting.

frames’s picture

Sorry, triple posting. Please don't blame me.
;-)

dutchie76’s picture

our mulitple site setup up on an apache dedicated server for which our host will set it up as required

/drupal-installation/
/drupal-installaiion/wordpress-blog/

.htaccess
/drupal-installation/.htaccess

Sites are installed in the normal way

/drupal-installation/sites/default
/drupal-installation/sites/site1
/drupal-installation/sites/site2
/drupal-installation/sites/site3

In Cpanel I have all URLs pointing to the /drupal-installation/

htaccess is as follows:

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
  Order allow,deny
</FilesMatch>

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php

# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
  ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# Force Trailing Slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteCond %{REQUEST_URI} !^/(admin|user|node|edit|filefield|content|imce|swftools)
RewriteRule (.*)$ /$1/ [R=301,L]

# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
  # There is no end quote below, for compatibility with Apache 1.3.
  ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

  # Cache all files for 2 weeks after access (A).
  ExpiresDefault A1209600

  # Do not cache dynamically generated pages.
  ExpiresByType text/html A1
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # If your site can be accessed both with and without the 'www.' prefix, you
  # can use one of the following settings to redirect users to your preferred
  # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  #
  # To redirect all users to access the site WITH the 'www.' prefix,
  # (http://example.com/... will be redirected to http://www.example.com/...)
  # adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
  # RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
  #
  # To redirect all users to access the site WITHOUT the 'www.' prefix,
  # (http://www.example.com/... will be redirected to http://example.com/...)
  # uncomment and adapt the following:

# non empty HTTP_HOST in the request
        RewriteCond %{HTTP_HOST} !^$ [NC]
# does not start with 'www'
        RewriteCond %{HTTP_HOST} !^www\. [NC]
# saves the value of HTTP_HOST in %1
        RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
# redirects using the saved URI (in RewriteRule) and saved hostname (in the last RewriteCond)
        RewriteRule ^(.*)$ "http://www.%1/$1" [L,R=301]

  # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at http://example.com/drupal uncomment and
  # modify the following line:
  # RewriteBase /drupal
  #
  # If your site is running in a VirtualDocumentRoot at http://example.com/,
  # uncomment the following line:
  # RewriteBase /

  # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

# $Id: .htaccess,v 1.90.2.3 2008/12/10 20:04:08 goba Exp $

Thanks alot for your assitance,

dutchie

frames’s picture

What I did was a bit different. Like I said, I have WP and Drupal setup in different directores, not WP inside Drupal, as you describe.

Summing up, all I needed for this to finally work as you wanted is:

1. Adding Alias /blog "/var/www/wordpress" (where WordPress is installed) to the Drupal virtual server config in Apache.
2. Modifying "WordPress address" and "blog address" in the General options.
3. Modifying the .htaccess used by WordPress.

I'm not 100% sure if that would work with WordPress inside the Drupal dir as you mention, but if you try and it does not, you could always get WP out of Drupal's path (better for upgrading Drupal in the future, I think). I don't think you would even need a WordPress virtualdir defined for it to work.