Member Avatar for bthaxor

Sorry if this is in the wrong section (PHP), but wasn't sure where to put htaccess issues....

Here's the deal - I have two domains, let's say domain1.com and domain2.com. On my web server, I have domain1 set up as the primary domain (/public_html/), and domain2 is an addon domain (/public_html/domain2.com/).

What I'd like to accomplish through .htaccess is to access my files from domain1 through domain2, which is shorter - so for example, if under domain1 I have a /admin/ folder (accessed through domain1.com/admin/), I'd like to also be able to access it through domain2.com/admin/. Would this be possible (without redirecting one entire site to the other, since they serve different purposes) through .htaccess?

Recommended Answers

All 9 Replies

Well, I have no idea how to do that with HTACCESS, but maybe you could post the server you use ... maybe someone knows of a tool that'll let you do that.

Member Avatar for bthaxor

I'm under shared hosting (Apache environment), so htaccess would probably be my best bet...

By accessing your files, do you mean in (php) code ? If so, if you use absolute paths the files should all be accessible to you.

Member Avatar for bthaxor

Something like this:

RewriteCond %{http_host} ^domain2.com [nc]
RewriteRule ^(.*)$ http://www.domain1.com/$1

If you want this for just specific files, just replace the .*

Thanks for that, but I already knew about a full-domain redirect - I mentioned in the OP that:

I'd like to also be able to access it through domain2.com/admin/. Would this be possible (without redirecting one entire site to the other, since they serve different purposes)

This is the real problem here =\

Thanks for the attempt though...

Member Avatar for bthaxor

So I would have to do this for every single file in both domains?

Not exactly what I was looking for, but I guess for one or two files I could employ this...

Perhaps I'm to blame though, I don't think I made myself clear enough - I would like to be able, for both domains, to be able to access ANY file or folder (e.g. http://domain1.com/file.txt or http://domain1.com/folder/) through the other domain (http://domain2.com/file.txt or http://domain2.com/folder/), AND VICE VERSA, so the two domains are 'interworking' to access the same files through their respective URLs. I know it's quite a big ask but... Just wanted to know if I could do anything like this.

Hmz, don't think that is possible throught htaccess, because that could cause infinite redirect loops. Sounds more like you want a load-balancer, but that would make only sense between two different servers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.