I have several sites on the same machine. 2 of them do not have their own hostname: www.example.com/test1 and www.example.com/test2. Respectively, their settings files can be found in drupal6/sites/www.example.com.test1/settings.php and drupal6/sites/www.example.com.test2/settings.php and both settings files have $base_url defined as http://www.example1.com/test1 and http://www.example2.com/test2 respectively. Both have clean-url activated.

The problem is: even tho the standard links are OK, all the administrative links on test1 point to their corresponding paths on test2. I have flushed caches and rebuilt menus on both sites.

All I can find is a vague recommendation to install the pathologic module and using that to rewrite all the URL.

Any thots appreciated.

Thank you.

Comments

No... the pathologic module

No... the pathologic module is for the content.

Do you mean that:
- you are on http://www.example.com/test1 and hover over the menu links and
- the admin links are http://www.example.com/test2/admin/something
- the other links are http://www.example.com/test1/something ?

That would be weird.

You said that the $base_urls are http://www.example1.com/test1 and http://www.example2.com/test2. Was that a typo?

Make sure that there is no settings.php file in sites/default, in case there is some typo and a site falls back to that.

------- Edit:

Also, don't include the "www" in the names of the sites/site-url directories, except if you have made sure in .htaccess that all user requests will have the "www" part. Or just never include it. The reason is that:

- With sites/example.com.test1, a request for http://www.example.com/test1 works fine.
- With sites/www.example.com.test1, a request for http://example.com/test1 fails and falls back to sites/default

Still Weird

Thanks for the input.

Do you mean that:
- you are on http://www.example.com/test1 and hover over the menu links and
- the admin links are http://www.example.com/test2/admin/something
- the other links are http://www.example.com/test1/something ?

That would be weird.

Yup. It's that weird.

You said that the $base_urls are http://www.example1.com/test1 and http://www.example2.com/test2. Was that a typo?

Yah, I mistyped. The hostnames are identical.

Make sure that there is no settings.php file in sites/default, in case there is some typo and a site falls back to that.

Good thot. There was a default.settings.php file in there. I deleted it; but it made no difference.

Also, don't include the "www" in the names of the sites/site-url directories, except if you have made sure in .htaccess that all user requests will have the "www" part. Or just never include it. The reason is that:

- With sites/example.com.test1, a request for http://www.example.com/test1 works fine.
- With sites/www.example.com.test1, a request for http://example.com/test1 fails and falls back to sites/default

Well, I was being pointlessly surreptitious. The two URL are:
http://ethel.ericx.net/beer
http://ethel.ericx.net/karen

However, it is the case that 'ericx.net' and 'ethel.ericx.net' resolve to the same host. So per your suggestion, I renamed the site directories containing the settings files by removing "ethel" from "ethel.ericx.net.beer" and "ethel.ericx.net.karen" as well as from the base_url variables.

While that did confuse my browser's authentication and it now forces all URL to the shorter host name; the strange problem persists: from the root page on http://ericx.net/beer all the links are correct; however, from any area in the administration area (there is no content at all yet) all the links point to http://ericx.net/karen/[whatever].

Eric W. Bates

More test examples

I created a page:

http://ericx.net/beer/node/1

Note that all the links from that page point to http://ericx.net/karen/[something] while all the links from the root page:

http://ericx.net/beer/

point to the correct http://ericx.net/beer/[something]

WEIRD

Eric W. Bates

Compare

Compare these:
http://ericx.net/beer/node/1
http://ericx.net/beer/?q=node/1

It must be a server problem with rewrites, because without clean URL it looks right. Try with RewriteBase either set to "/" or commented out.

If you are unlucky and the server requires a RewriteBase set to the particular subdirectory of one site, then your only option will be to use proper subdomains to access the two sites without their subdirectory paths. (Or not to use clean URLs.)

Also, have you added any complicated rewrites in .htacess?

You're brilliant. I will

You're brilliant.

I will poke at that idea; but I think you have it.

I have run an ISP since 1995; so the config on my home server has gone thru dozens of revisions. I will dump the rewrite log and see what comes up.

Eric W. Bates

Got it working

OK. The whole clean URL thing seems kind of hackish; but I finally found some rewrites that allow multiple sub-directory sites co-exist on the same virtual host.

  RewriteEngine on
  RewriteLog /var/log/apache/rewrite_log.ethel
  RewriteLogLevel 0

...

  Alias /beer /usr/local/www/drupal6
  Alias /karen /usr/local/www/drupal6
  <Directory /usr/local/www/drupal6>
    # The following cuteness is simply to allow drupal to use
    # "clean URLs" e.g. '/drupal/admin/settings/clean-urls'
    # instead of '/drupal/?q=admin/settings/clean-urls'
    RewriteEngine on
    RewriteOptions inherit

    #RewriteBase /beer
    RewriteCond %{REQUEST_URI} ^/beer
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /beer/index.php?q=$1 [last,qsappend]

    #RewriteBase /karen
    RewriteCond %{REQUEST_URI} ^/karen
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /karen/index.php?q=$1 [last,qsappend]
  </Directory>

I am using apache 2.2.9 and this is a snippet from the main httpd.conf (I hate using .htaccess files, they slow down apache response).

Note that even if you have RewriteEngine on in the same virtual host (I do) you have to specify that it be on again within the Directory block. Also, if you want any logging you have specified in the virtual host to work (you can't declare any logging within the Directory block), you seem to have to specify the inherit option.

Using Rewrite statements within a Directory (or a .htaccess) is a little weird, and the documentation on the apache site doesn't seem to be completely accurate (or I'm just reading it wrong). According to the docs, inside a directory block the pattern used to match rules is truncated by removing the portion which matches the current physical path. Hence the need for RewriteBase. In theory, you use RewriteBase to tell mod_rewrite what URI path to use instead of the physical one. Sadly, it seems that you can't use more than one RewriteBase per directory (hence my problems above).

In spite of the documentation to the contrary, it seems that statements inside a directory are, in fact, truncated; but both /beer/foobar/baz and /karen/foobar/baz are both truncated to foobar/baz without any RewriteBase.

In addition, the documentation says that the truncated portion of the path will be reapplied to the beginning of any rewrite results. However, this is not happening; so the final RewriteRule matches the entire truncated pattern (e.g. foobar/baz) and then writes out the whole intended URI (e.g. /beer/index.php?q=foobar/baz.

The log snippet below is log level 2. Note that at the virtual host level, the URI is passed, but finally at the perdir level, it gets the rewrite we want.

192.168.0.8 - - [23/Oct/2008:20:24:22 --0400] [ethel.ericx.net/sid#285ce3d0][rid#29670058/initial] (2) init rewrite engine with requested uri /beer/admin/build/block
192.168.0.8 - - [23/Oct/2008:20:24:22 --0400] [ethel.ericx.net/sid#285ce3d0][rid#29670058/initial] (1) pass through /beer/admin/build/block
192.168.0.8 - - [23/Oct/2008:20:24:22 --0400] [ethel.ericx.net/sid#285ce3d0][rid#29670058/initial] (2) [perdir /usr/local/www/drupal6/] rewrite 'admin/build/block' -> '/beer/index.php?q=admin/build/block'

I hope this helps someone.

Eric W. Bates

nobody click here