Forum Moderators: phranque
I am having directories for domains at:
/home/www
(like /home/www/domain1.com, /home/www/domain2.fi...)
Here is my rewrite_mod code:
# Point addresses like http://domain1.com/something
# to /home/www/domain1.com/something
RewriteCond /home/www/%{HTTP_HOST} -d
RewriteRule ^(.*) /home/www/%{HTTP_HOST}$1 [L]# Point addresses like
# http://sub.domain1.com/something to
# /home/www/domain1.com/sub/something
RewriteCond %{HTTP_HOST} ^([^.]+)\.(.*\..*)$
RewriteRule ^(.*) /home/www/%2/%1$1
This works most cases fine. But if there is directory:
/home/www/domainx.com/www/somedir
and I try to open it by typing:
[domainx.com...]
it wont work. Anyhow [domainx.com...]
will work!
Error message that I get is:
An error occurred while loading [domainx.com...]
Unknown host domainx
What might be the problem? And how to fix it. And also, am I doing this sensible way at all?
Welcome to WebmasterWorld [webmasterworld.com]!
This missing trailing slash problem would normally be fixed by Apache mod_dir, but it's possible that your host has UseCanonicalName on, which often causes this problem.
You can use a technique something like this to detect and fix a missing trailing slash:
# If the requested URL-path does not end with a dot followed by anything other than a
# slash (signifying that it ends in a filename)
RewriteCond %{REQUEST_URI} !\.[^/]+$
# and it does not end in a slash (which would signify that it is a directory index request)
RewriteCond %{REQUEST_URI} !/$
# then add a trailing slash
RewriteRule (.*) /$1/
Ref:
UseCanonicalName [httpd.apache.org] documentation
Apache mod_dir [httpd.apache.org] documentation
Jim