httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike <m...@typenexus.com>
Subject [users@httpd] Apache Trailing Slash Fix not working on sub-domain rewrites.
Date Sun, 23 May 2004 05:33:28 GMT
My research has not yielded any solutions. I have tried official Apache 
1.3 doc's, Google, and several other related websites without success.

The URL rewrites to directories under my site's sub-domains break when 
no trailing slash is used. I am on a virtual hosting account which 
allows any .htaccess directive including rewrites, but I cannot view or 
modify the httpd.conf or other daemon config files...
    * http://subdomain1.website.com (without trailing slash) - Works
        ...The trailing slash is added in a rewrite.
    * http://subdomain1.website.com/directory (without trailing slash) - 
Breaks
        ...Becomes http://website.com/subdomain1/directory/

This is what I have setup:
/home/username/webroot/.htaccess
    <code>
    # Setup URL Rewriting
    RewriteEngine on
    RewriteBase /
    ##########
    # Begin Request Evaluations
        RewriteCond %{HTTP_HOST} ^www\.website\.com$ [NC,OR]
        RewriteCond %{HTTP_HOST} ^website\.com$ [NC]
    RewriteRule ^.*$    -    [L]
    # Request not for a sub-domain. Stop here.
    ##########
    # Evaluate: subdomain1
        RewriteCond %{HTTP_HOST} ^subdomain1\.website\.com$ [NC]
        RewriteCond $1    ^(.+)$
    RewriteRule ^(.*)$ /home/username/webroot/subdomain1/%1 [NS,L]
    # Stop here.
    </code>
/home/username/webroot/subdomain1/.htaccess
    <code>
    # Setup URL Rewriting
    RewriteEngine on
    RewriteBase /
    ##########
    # Fix Absent Trailing Slash
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteCond %{HTTP_HOST}    ^(.+)$ [NC]
    RewriteRule ^(.+[^/])$    $1/ [R]
    # Stop here.
    </code>

I (unsuccessfully) tried applying the Fix from the Apache 1.3 URL 
Rewriting Guide [http://httpd.apache.org/docs/misc/rewriteguide.html]. I 
have also tried many variations of the fix all without success.

I googled the words "trailing slash fix subdomains" and found 
http://www.webmasterworld.com/forum92/1462.htm which explained "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."

I asked my server admin and UseCanonicalName is turned ON in httpd.conf. 
I am only 1 user with a virtual account so I cannot ask that 
UseCanonicalName be turned off.

The forum explanation offered a fix based upon the assumption that all 
files would have (file.xyz) extensions. My website runs certain scripts 
which have no file extensions so that would not be a viable solution. I 
think the Trailing Slash Fix from the Apache 1.3 URL Rewriting Guide's 
technique of checking if a request is a directory with "RewriteCond 
%{REQUEST_FILENAME} -d" would be a better approach.

If someone is familiar with a website or solution to this problem, it 
would be of great help. I am hoping someone might be able to point me in 
the right direction, suggest an alternate approach, or identify where I 
have made a mistake.

My server is running...
 Server OS: FreeBSD 4.3-RELEASE
Web Daemon: Apache/1.3.26 (Unix) FrontPage/4.0.4.3 mod_fastcgi/2.2.12

Thank you for your time and attention.
-Mike





---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message