1

I have a hosting account with godaddy. Its a linux system running apache. The way they do their setup is your primary domain is the root folder. When you add a subdomain its in a subfolder of the root which sucks. I want to setup a subfolder structure to organize my domains.. I called godday support and they said to use redirects.. but did not know how to do that..

How its setup now:

primary domain:

www.domain.com /
sub.domain.com /sub

I want to create a directory structure and then redirect to each but only show www.domain.com in the url

www.domain.com /domain/www
sub.domain.com /domain/sub

I tried using:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ domain/www [L]

but it just changes the url to www.domain.com/domain/www

Can this be done in htaccess?

2 Answers 2

1

I run my own server on a similar principle, this is my configuration:

It should work with little modification for you assuming that GoDaddy supports this type of thing (it seems to from your question), except you'll need to change paths obviously. This configuration rewrites into folders like /var/www/vhosts/example.com/www for www.example.com.

RewriteEngine on

# Directory listing icons!
RewriteRule   ^/icons/(.*)$   /var/www/icons/$1       [L]

# Ensure there is no www.
RewriteCond   %{HTTP_HOST}    ^www\.(.*)$     [NC]
RewriteRule   ^(.*)$          http://%1$1     [R,L]

# Special case for the base domain
RewriteCond   %{HTTP_HOST}    ^(localhost|[^.]+\.[^.]{1,8}(\.au)?)$   [NC]
RewriteRule   ^(.*)$          /var/www/vhosts/%1/www$1

# Rewrite subdomains into subdirectories
RewriteCond   %{HTTP_HOST}    ^(.*?)\.(localhost|[^.]+\.[^.]{1,8}(\.au)?)$   [NC]
RewriteRule   ^(.*)$          /var/www/vhosts/%2/%1$1
0

Let if your original www.domain.com document root is point to /user../public_html/www.domain.com/ and you want to change that document root to /user../public_html/www.domain.com/domain/www try this conf on your.htaccess to change your www.domain.com document root to /domain/www

RewriteEngine on
RewriteRule ^/$ /domain/www/

Taken from How to modify httpd>documentroot via .htaccess?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.