0

Hi Stack Overflow community,

I have a question regarding a web setup. My main website is in the root of my "public_html" directory. Within this directory, I have created a subfolder called "subsite". So the file address to this is: "public_html/subsite". To access my main site, I go to www.example.com. I also have an add-on domain that points to my 'subsite' directory, which is www.subsite.com.

My urls are not behaving correctly. When I go to www.subsite.com, it points to the appropriate subdirectory within my main site's root folder for the homepage only. However, once I start navigating to other pages with my subsite, the url changes back to www.example.com/subsite/about.php for instance. I would like to mask all urls for visitors so when a user goes to a page on my subsite, the page url would be www.subsite.com/about.php.

When a user navigates to the site in this way: "www.example.com/subsite/..." it will re-direct them to www.subsite.com with the appropriate address. If pages could redirect as well, that would be great! Ex. "www.example.com/subsite/about.php" redirects to "www.subsite.com/about.php".

Also, I'm having similar problems with my subdomains. "customers.example.com" rewrites to "www.example.com/customers/..." when I navigate to inner pages. I think this is a similar problem to my main site stuff happening above.

Thanks for any help! If you have a good tutorial that answers this, point me there. If not, I'd appreciate any self-help you might offer!!

kaffolder
  • 381
  • 3
  • 10
  • 21

1 Answers1

0

As a temporary fix, try adding these lines ot your root .htaccess file :

RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule ^subsite(/(.*))?$ http://www.subsite.com/$2 [L,QSA,R=301]

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule ^customers(/(.*))?$ http://customers.subsite.com/$2 [L,QSA,R=301]

But you should realy try to fix the source problem of the redirection.

Oussama Jilal
  • 7,669
  • 2
  • 30
  • 53