CodeIgniter Forums
simple (?) htaccess question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: simple (?) htaccess question (/showthread.php?tid=22907)



simple (?) htaccess question - El Forum - 09-23-2009

[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


simple (?) htaccess question - El Forum - 09-23-2009

[eluser]bretticus[/eluser]
Read this.


simple (?) htaccess question - El Forum - 09-23-2009

[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


simple (?) htaccess question - El Forum - 09-24-2009

[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