Forum Moderators: phranque
#condition like if,while
RewriteCond %{HTTP_HOST} ^site\.com$ [NC]
#procedure if the condition satisfied
RewriteRule ^(.*)$ [site.com...] [R=301,L]
and is working fine the root site, but the spanish site is located in the folder /spanish/ and I try something like:
#condition like if,while
RewriteCond %{HTTP_HOST} ^site\.com/spanish/$ [NC]
#procedure if the condition satisfied
RewriteRule ^(.*)$ [site.com...] [R=301,L]
Also I try:
#condition like if,while
RewriteCond %{HTTP_HOST} ^site\.com\/spanish/$ [NC]
#procedure if the condition satisfied
RewriteRule ^(.*)$ [site.com\...] [R=301,L]
But not works, can you give some help on this?
thanks
If you have not done so, completely flush (delete) your browser cache, and then test again.
A more-comprehensive solution, assuming that you do not use any other subdomains except for "www" is
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
Regarding your line "RewriteCond %{HTTP_HOST} ^site\.com/spanish/$ [NC]", do not try to test the URL-path in a RewriteCond checking HTTP_HOST. The HTTP_HOST variable contains only the hostname sent by the client, optionally followed by a period indicating an FQDN, and optionally followed by a port number. It will never contain any part of the URL-path unless the client is badly-broken. The URL-path should be tested in the RewriteRule pattern instead.
Jim