Hm, that fist conditin was suppsoed to be:
with a blank before [nc].
The [nc] simply says not to worry about the case, if it's lower or
upper case. It can be left out but it might then indicate to take the
value as entered with no transformation. Not sure.
As to why a $ may have been needed at the end of the host value to
test against, I don't know. I'm not seeing that need in my own
applications, they work just like that.
The trailing slash I didn't mention since yuor server already did add
that anyway. So I think that's redundant.
I have directives to add that but it's different from yours, and it's
only to be used on servers where it's not already being added.
I'm confused LOL
There are usually small diffrences in how Apache https.conf is set
up (a master file that's similar to the .htaccess file but with a
lot more directives that apply to the whole server) - but you
generally won't have access to that file on shared hosting, as it's at
a higher level than your home directory. So you use the .htaccess file
which available to be used in the root or lower directories, where you
have access.
Sometimes diretcives used in httpd.conf conflict with what you try to
use in .htaccess. Some you can override, some you cannot. Mystery to
me. It's often just a lot of trial and error.
Sometimes if you have Cpanel it can actually geenrate the .htaccess
diretcives for some kinds of redirectons, even the ones for the
canonical domain form. I haven't tried on mine, I think I saw it
mentioned. Often what Cpanel concocts will conflict with other things
or mess up outright so I don't trust it too much to do things right.
But look what happens here:
http://web-sniffer.net/?url=http%3A%2F%2Fwww.desarrollowebdequeretaro.com%2Fcomaiz&submit=Submit&http=1.1&gzip=yes&type=GET&uak=0
http://www.desarrollowebdequeretaro.com/comaiz
gets 301 redirected to:
http://www.comaiz.com.mx/comaiz/
which is obviously incorrect.
It shoudl have been 301 redirected to
http://www.desarrollowebdequeretaro.com/comaiz/
which should in turn get 301 redirected to the add-on domain
http://www.comaiz.com.mx/
by proper directives in the /comaiz/ folder.
You had the
http://www.desarrollowebdequeretaro.com/comaiz/
redirection ok the other day.
This however works as expected:
http://www.desarrollowebdequeretaro.com/comaiz/
and gets rdirected to
http://www.comaiz.com.mx/
So what doesn't work is the thing about adding the trailing slash.
SInce it was working the other days without what you just added now,
which is:
# trailing slash
# If URL-path does not contain a period or end with a slash
RewriteCond %{REQUEST_URI} !(\.|/$)
# add a trailing slash
RewriteRule .*
http://www.comaiz.com.mx%{REQUEST_URI}/ [R=301,L]
If you added this to the .htaccess in the /comaiz/ folder then see
what this does:
I access
http://www.desarrollowebdequeretaro.com/comaiz so the value
of REQUEST_URI will be:
/comaiz
Then trailing slash directive kicks in and does as instructed a
redorection to
http://www.comaiz.com.mx strung out with the
REQUEST_URI value /comaiz added after it and finally the trialing
slash is added. Clearly incorrect.
It works OK if the access was to
http://www.comaiz.com.mx/somefolder ,
which goes through the same .htaccess file .
So the only way that directive could work is if it were modified to
add as a condition that the http_host is specifically
comaiz.com.mx or
www.comaiz.com.mx .
So it would be this and stated twice once for each variant of the
domain:
~~~~~~~~~~~~
# trailing slash
# If URL-path does not contain a period or end with a slash
RewriteCond %{REQUEST_URI} !(\.|/$) [AND]
RewriteCond %{HTTP_HOST} ^
comaiz.com.mx
# add a trailing slash
RewriteRule .*
http://www.comaiz.com.mx%{REQUEST_URI}/ [R=301,L]
# trailing slash
# If URL-path does not contain a period or end with a slash
RewriteCond %{REQUEST_URI} !(\.|/$) [AND]
RewriteCond %{HTTP_HOST} ^
www.comaiz.com.mx
~~~~~~~~~~~~~
Remember the above goes into the /comaiz/ folder which is at the same
time root of
comaiz.com.mx (hence the problem)
In the root of the MAIN domain you'd have the regular directive
without the need to test for the HTTP_HOST value:
~~~~~~~~~~~~
# trailing slash
# If URL-path does not contain a period or end with a slash
RewriteCond %{REQUEST_URI} !(\.|/$)
# add a trailing slash
RewriteRule .*
http://www.desarrollowebdequeretaro.com%{REQUEST_URI}/
[R=301,L]
~~~~~~~~~~~~~
In the above you need not worry about which domain is being acccess
sicne the only one that could be is the main domain, otherwise we'd
not be accessing its root.
But as I said, I believe these directives are not needed on your
server at all, as most servers already compensate for the missing
trailing slash and add it themselves and test and do the 301
redirection properly. In rare cases one needs to do it like this or
similar fashions.