I have drupal running on the server for my home network. It runs DNS, and all machines search within the domain, so a request for "www" becomes "www.example.com". (Obviously my domain isn't example.com, but I'll use that here for simplicity).

My drupal site is accessible from "www.example.com", "example.com", "www" and by IP. The site works fine on all four, but for "www" and by IP I have to turn off clean URLs or manually add the "index.php?q=". Clean URLs work fine for "www.example.com" and "example.com".

My .htaccess (note that I use virtualdocumentroot):

<FilesMatch "(\.(engine|inc|install|module|sh|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|Entries.*|Repository|Root)$">
  Order deny,allow
  Deny from all
</FilesMatch>
# Set some options.
Options -Indexes
Options +FollowSymLinks
# Customized error messages.
ErrorDocument 404 /index.php
# 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
</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
</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
</IfModule>
# Reduce the time dynamically generated pages are cache-able.
<IfModule mod_expires.c>
  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 prefix www.
  # you can use one of the following settings to force user to use only one option:
  #
  # If you want the site to be accessed WITH the www. only, adapt and uncomment the following:
  RewriteCond %{HTTP_HOST} !^www\.systemparadox.no-ip.org$ [NC]
  RewriteRule .* http://www.systemparadox.no-ip.org/ [L,R=301]
  # Rewrite current-style URLs of the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  # For standard virtualhosts
  #RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
  # For virtualdocumentroot
  RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
</IfModule>

Thanks
Simon

Comments

magico’s picture

Status: Active » Closed (fixed)

Closing support requests older than 1 month.