Reputation:
I am using godaddy and what I want to do is when someone types in a domain address I want it to automatically redirect to a folder rather than placing the files on the root so its more organised.
How do I write this in .htaccess?
Upvotes: 0
Views: 328
Reputation: 5766
Simple Rewrite
Unless a condition exists the Rewrite will not do stuff. Here's a code that will actually work in no subfolder is specified. e.g http://domain.com will be redirected to http://domain.com/subfolder/somefile
You can also point it to a subfolder and not a file, just remove the somefile.php and your set. Remember to change the value of "DOMAIN" and "SUBFOLDER"
#Turns the engines on!
rewriteEngine on
# Checks Condition, "Does it have a subfolder specified?"
rewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
# Does its Rewrite Magic
rewriteRule ^$ http://%{HTTP_HOST}/subfolder/somefile.php [R,L]
Upvotes: 0
Reputation: 7797
RewriteEngine on
RewriteRule (.*) subfolder/$1 [L]
The L is needed so that if there are other rules they don't get executed (think infinite loop); this is written as a catch-all.
Upvotes: 1
Reputation: 5779
Do you use GoDaddy for your DNS only, or for your web hosting as well? Their economy plan does not allow you to host multiple websites (http://www.godaddy.com/gdshop/hosting/shared.asp?ci=9009)
GoDaddy has a nice online help, you should take a look: http://help.godaddy.com/article/4688
Upvotes: 1