I don't know if I'm doing this right or not, so please bear with me. I'm a big fan of deprecated URLs - specifically, no "www" addresses. So, I want to redirect all "www" requests to "non-www". That's pretty straightforward so far. I have easily done this using the following method: RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.mydomain\.net$ [NC] RewriteRule ^(.*)$ http://mydomain.net/$1 [R=301,L] Code (markup): The problem is, this code is fine for the domain. But I cannot get it to work for the subdomains. So, my questions are as follows: A) do I need a .htaccess file in my subdomain, or can I make one top level to hit them all? B) why does this not work with subdomains? I tried putting the subdomain name in - i.e.; sudomain.mydomain.net - in the Rewrite. I don't know what I'm doing wrong here. I just want to redirect www to non-www for my domain, and ALL of its subdomains. Thank you.
I'm pretty new to mod_rewrites ... I wonder if this will work... RewriteEngine On RewriteCond %{HTTP_HOST} ^.*mydomain.net$ RewriteRule ^(.*)$ %{HTTP_HOST}/$1 [R=301,L]
Hi, Your .htaccess for the main domain is in the top web directory of the main domain. .htaccess files for a subdomain should be located in the top web directory of this subdomain. Jean-Luc
I would try this : RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.subdomain\.mydomain\.net$ [NC] RewriteRule ^(.*)$ http://subdomain.mydomain.net/$1 [R=301,L] Code (markup): Jean-Luc
Looking for the same solution. I've set the top domain with the code from the first post. That works great! But now also looking for a solution for a subfolder. I want to redirect 301, from http://www.domain/sub/327.html to http://domain/sub/327.html Anyone has got a solution?
Jean-Luc: That was the first thing that I tried, borrowing the logic from the top-level redirect. However, it produced a 404 error. ***edit*** I lied. Actually, it produced a server error. ("cannot find server", to be exact) Removing the .htaccess file clears up the problem, but is not a solution.