Welcome Guest, Not a member yet? Register   Sign In
simple (?) htaccess question
#1

[eluser]mvdg27[/eluser]
Hi guys,

I think I have a simple htaccess question, but I can't find on Google how to achieve it. I hope some htaccess experts can give me a hand here Smile

Ok. I what I want to do, is redirect a subdomain, to the same url, without the subdomain (or actually the www-subdomain).

So for example:

http://test.mydomain.com => http://www.mydomain.com

and

http://test.mydomain.com/controller/function => http://www.mydomain.com/controller/function

Any ideas? Preferably in a way that doesn't hurt the Google ranking.

Thanks! Michiel
#2

[eluser]bretticus[/eluser]
Read this.
#3

[eluser]InsiteFX[/eluser]
Here.

Code:
# Redirect non-www to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) http://www.domain.net/$1 [R=301,L]

Enjoy
InsiteFX
#4

[eluser]mvdg27[/eluser]
@bretticus: Thanks! Great resource, it's in my bookmarks now!

@InsiteFX: Thanks. Your code works, but not exactly how I wanted it. If I type http://mydomain.com it redirects to http://www.mydomain.com, which is good. However when I type: http://test.mydomain.com, it redirects to http://www.mydomain.com/test/, which is not what I'm looking for. It shouldn't append the subdomain as a URI-element




Theme © iAndrew 2016 - Forum software by © MyBB