subdomain redirect

Tenant

New Member
Messages
13
Reaction score
0
Points
0
I am looking for a way to create a redirect that will do the following:

redirect any subdomain to the same set of files without changing the url.

We have the wildcard redirect in place but we are hosting multiple websites on our hosting package so the wildcard is sending the subdomain to the wrong website. We need to create a redirect that will direct them to the correct files.

If possible we would like to use an htaccess redirect but if there is another matter we are open to suggestion.

example

test1.website.com
test2.website.com
test3.website.com

will all use the files found in public_html/website.com/files

The goal is for our sales team to put their name as the subdomain without us having to create new subdomains for everyone. The website will log the subdomain that is being used to give credit for the sales.

---------- Post added at 01:47 PM ---------- Previous post was at 09:51 AM ----------

I have tried the following but it just shows

RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{HTTP_HOST} !^www\.parentsite\.com?$
RewriteCond %{HTTP_HOST} ^([^.]+)\.correctsite\.com?$
RewriteRule ^$ /correctsite [L]

parentsite being the site that the account was created under
/correctsite being the name of the folder that the addon domain was created in.

But is just shows test.correctsite.com/directory

im looking for a way to prevent this url change
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Do you mean someone going to "http://test.correctsite.com/" gets externally redirected to "http://test.correctsite.com/correctsite/"? What about "http://test.correctsite.com/foo"? From the rewrite rules, it looks like the request won't be rewritten at all. Do you have any other rewrite rules in that or any other .htaccess files?

You seem to be using three different example directory names and two different domain names. Pick one and stick to it. Better yet, use the real ones so we can see what's really going on.
 
Last edited:
Top