I am trying to use multiple domains on the same webserver but get a different website depending on the domain which was entered. I think this is possible using HTACCESS but I couldn't find anything useful on google.
Here is an example:
www.a.com -> index.php
www.b.com -> /b/index.php
But if someone wants to view B the URL should still be www.b.com with no trace of www.a.com.
Related
I have two domains, lets say www.A.com and www.B.com which are located on the same server. The directory is like this:
/html/index_of_A.php
/html/content_of_b/index_of_B.php
Now i want to configure an .hataccess file, which does the following things:
1) redirect users which enter A.com to /html/index_of_A.php (which is actually www.A.com) and
2) redirect users which enter B.com to /html/content_of_b/index_of_B.php
At the end, users enter two domain names (a.com and b.com) and they are getting redirected respectively to the specific folders of the domains.
Is that possible with htaccess?
The reason for this is, that i have two domain names, but they are on one server. Now I want to seperate both of them, to make "two different web pages".
Further, the users should always get rediretet to the www version.
Unfortunately I have no idea how to do that... I did some searches and tried different methods, but no success :(
Hope anybody can help me, appreciate that!
If I understand you problem correctly, there is no need to configure an .htaccess file.
You can solve your problem by slightly reorganizing your folder structure.
This is how I would solve it:
[folder for domain A/index.php]
[folder for domain B/index.php]
Configure your domain registration for www.A.com to point to [folder for domain A]
Configure your domain registration for www.B.com to point to [folder for domain B]
This way there is no need for an .htaccess file unless you are setting one up for security reasons (not redirection) AND you don't have to muddle through www.A.com's files when you need to focus on www.B.com.
I hope this helps.
What is best practice for doing this? Should I have duplicate content at each domain or should I redirect from one to the the other, i.e. all traffic to the .co.uk domain redirected to the .com domain?
Best practice is to send them all to one web server.
By default the server will not care which domain is pointed at it and will show the home page as domainx.com if you to it from domainx.com.
However there are two possible issues with this that come to mind:
The person who created the website hopefully only used relative links. (The contact us button points to contactus.htm instead of http://domainx.com/contactus.htm ) If not, some links might change the user from domainx.co.uk to domainx.com.
Search Engine Optimisation: Its better SEO wise if all the links to your site point to one domain name rather than appearing as several less popular sites.
You can get everyone on the same site by using a RewriteRule or 301 Redirect to the primary site. Or you can make every hyperlink on the site absolute and point to the primary domain.
I have written a function that "extract" the domain from hostname.
e.g.
www.domain.com -> domain.com
domain.net -> domain.net
www.domain.co.uk -> domain.co.uk
www.subdomain.domain.tx.us -> domain.tx.us
and so on.
However I was unable to find list of all subTDL's.
Function also return wrong result for domains such nominet.uk
Any suggestions where I can find all of them?
Or any other way to do same function, but with using let say DNS?
It's impossible to this using the DNS (or any other algorithm for that matter) as there's no formal definition of what is a "subdomain".
The only practical solution at the moment is the "public suffix" list available via http://publicsuffix.org/.
This list contains those domains known to the administrators where different subdomains are issued to different third parties.
Its primary use is to help enforce cross-domain security policies - for example a server for "foo.co.uk" mustn't be able to set a domain cookie on "co.uk" which is then served to any other subdomain.
There is publicly available file describing all sub TLD's located at:
http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1
.htaccess redirect multiple files to same number in subfolder.
I need to accomplish the following:
receive these request at the main domain (root directory)
domain.com/customer-1.html
domain.com/customer-2.html
domain.com/customer-n.html
direct them to
domain.com/customer-1/
domain.com/customer-2/
domain.com/customer-n/
and in sub-directories:
/customer-1/
/customer-2/
/customer-n/
I need each sub-directory to rewrite the url to main domain
domain.com/customer-n/ ==>http://domain.com
the idea is to serve multiple customer essentially accessing same type of application on their own subdirectory but to the public to show that they are not sharing that domain.
and the subdirectories are all instances of the same joomla install with different templates.
thanks
first of all: it is not a good practice to share a database across multiple customers.
if you mean to share the same codebase, it is ok.
i dont know much about joomla, but must cms support multiple sites.
which mean they can serve independent domains, with the same codebase but different databases.
this may help:
Multi Sites
MS Control
another thing is to put your customers on a subdomain:
customer1.example.com
customerN.example.com
Say I've got two distinct domains:
1) http://sub.test.org
2) http://m.sub.test.org
for my website.
I want domain n.1 to be associated to the full-version of my website (intended to be mainly visited by desktop user agents) and domain n.2 to be associated to its mobile-version (intended to be mainly visited by mobile user agents).
Both of the versions reside on an external host which runs an instance of Apache webserver I can't control directly, but I am able to post .htaccess files and therefore I want them to control domain redirecting stuff (I don't want to use Javascript neither PHP server-side logic)
The directory structure on the external host is, say:
directory / --> contains full-version website's pages and resources
(index.html is the entry-point)
directory /mobile --> contains full-version website's pages and resources
(index.html is the entry-point)
and the mappings are:
http://sub.test.org -> /index.html
http://m.sub.test.org -> /mobile/index.html
Now, my desired scenarios are as follows:
A) When user asks for URL http://sub.test.org:
IF current URL is http://m.sub.test.org/* (this means: if user is currently into the mobile-version) THEN serve page http://sub.test.org/index.html
ELSE:
IF user agent is mobile THEN redirect to URL http://m.sub.test.org
ELSE serve page http://sub.test.org/index.html
B) When user asks for URL http://m.sub.test.org - no matter what the user agent is - user should be redirected to URL http://sub.test.org.
My questions:
What would be the syintax of the associated .htaccess file?
Do I need more than one?
Where should I place it/them ?
Any help/code hint would be really appreciated, because I have really a few experience with Apache .htaccess files and regexps! Thanks in advance.
http://httpd.apache.org/docs/current/howto/htaccess.html
You would most likely need 2
place one it in the root and one in /mobile