Forum Moderators: phranque
# If URL is seconddomain.com but no subfolder is requested, redirect to domain.com.
RewriteCond %{HTTP_HOST} seconddomain.com
RewriteCond %{REQUEST_URI} !^/subfolder/
RewriteCond %{REQUEST_URI} \..+$
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
# rewrite from www to non-www.domain.com
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L]
# add a trailing slash to any subfolder requests without one
RewriteCond %{HTTP_HOST} domain.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} [^/]$
RewriteRule ^(.*)$ $1/ [L,R=301]
ErrorDocument 404 /error404.htm
ErrorDocument 400 /error400.htm
[edited by: jdMorgan at 3:38 am (utc) on May 26, 2008]
[edit reason] De-linked [/edit]
You may be able to fix the ErrorDocument problem by adding a second RewriteCond to your first rule:
RewriteCond %{REQUEST_URI} !^/error
Also, change the RewriteRule substitution URL to use the non-www domain!
There are several othe problems in this code. Get the DocumentRoot problem fixed, and then let's proceed with the rest.
Jim
There appears to be a bug in mod_dir which causes problems when the DocumentRoot has a trailing slash (i.e., "DocumentRoot /usr/web/") so please avoid that.
Jim
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ [%1...] [R=301,NC,L]
RewriteRule (.*) http://%1/$1 [R=301,L]
Other than that, the post above was simply pointing out that this rule invokes a client redirect, and not a server-internal rewrite. Since mod_rewrite and regular expression patterns are so picky about every little character being correct, those of us who deal with it a lot like to use precise terminology to make things as clear and correct as possible... :)
Jim
I am not impressed that a so-called "Search Engine Friendly" component makes such a problem for the site.
Then again I have a very low opinion of everything Joomla! It's a poorly implemented pile of junk.
A URL that ends with a trailing / is a folder, or a call for the index file within a folder. It is itself not directly a file.