Hi I have been developing a site and the test subdomain got indexed, i forgot to block with robots.txt. I would like to redirect the subdomain and all the pages, For both www and non www to www.domain.net for eg dev.domain.net to domain.net www.dev.domain.net/page to www.domain.net www.dev.domain.net/page to www.domain.net There is no .htaccess at all at present so would like all requests for to be redirected to www.domain.net if possible. At the same time if i can do a non www to www redirect that would be great. Any help would be very gratefully received, thanks guys.
.htaccess alone won't be able to do this for you. You will need to setup your own nameservers or at least be able to configure access to your main nameservers to change the requests that come in to it. I fixed this by pointing my DNS information to one of my servers which returned a script generated response to wherever the request came from. Figuring out how to do this took me a couple days and I even ended up writing a tutorial for myself just incase I had to do it again. I'll see if I can find that tutorial and post it or send it to you.
Assuming the subdomain is resolving fine and I don't see anywhere where you say you deleted it then the following in the .htaccess of the subdomain should do what you ask: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.domain\.net[NC] RewriteRule (.*) http://www.domain.net/$1 [R=301,L] Code (markup): You can also use it on the main domain to redirect non-www requests to www versions.
# Extract the subdomain part of domain.com RewriteCond %{HTTP_HOST} ^([^\.]+)\. domain\.com$ [NC] # Check that the subdomain part is not www and ftp and mail RewriteCond %1 !^(www|ftp|mail)$ [NC] # Redirect all requests to a php script passing as argument the subdomain RewriteRule ^$ http://www.domain.com/%1/details.html [R,L] I use this code for wildcard dns, might help.
thanks guys. As we are continuing to use subdomain, i have blocked for time being. Am no apache expert. The domain root is forwarded with an apache proxy (my brother tells me, hes no good with htacess) ie domain/folder is redirected from domain http//domain redirects to www.domain fine however domain/folder typed direct into address bar remains as this and does not redirect to www. I am using a std non www to www htaccess at present.
If you use the .htaccess I posted above on the main domain then it should be redirecting domain/page to www.domain/page. Or post your .htaccess so it can be debugged.
Hi Htaccess as is with the actual domain having probs with. Site is written in java. RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.cpdregister\.net [NC] RewriteRule (.*) http://www.cpdregister.net/$1 [R=301,L] this should redirect from http://cpdregister.net/cpd/ to http://www.cpdregister.net/cpd/ but doesnt thanks for help.
You could try using RewriteLog, http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritelog see if that sheds any light on the issue, but what you have should work.