.htaccess changing domain but not the rest of url - .htaccess

I'm out of ideas to achieve the below:
I host 2 websites "A" and "B" on one server, as most of their elements are common.
"B.com" is web forwarding package - it forwards the user to "A/indexB.php".
All I want to achieve is when someone enter the "B" url it redirects to "A/indexB.php" document, but the "B" domain should remain.
I can't use "B" as Masked Redirection Type, as people browsing the "B" website instead of seing links like "B/link" they would see only "B".
Is there any .htaccess solution?

If "B" redirects to "A/indexB.php" then where should redirect "B/link"?
I'm not an expert, but it seems that you're trying to adapt global redirect (based on domain -- i.e. redirect everything from B.com) to a specific targed (script A/index.php). I'm not pretty sure, if this is possible.
I would consider using server / hosting configuration for defining a permanent redirect between "B" and "A". Or even would think about configuring "B" domain as Addon Domain (which can point to a particular path in your account, not only root). But this again returns me to the question in first line and I'm a bit confused, if it is possible, what you want to achive?

Related

Rename directory name using .htacess

It's hard to explain, I would like to do something like below but I don't know how.
I currently own two different domain names and have one website.
Can I have two domains pointing to the same website but the URL only shows whatever domain is entered in the first place?
For example, when I type in 'domain123.com', it takes me to my website (IP address 111.222.333) with the URL shown as 'domain123.com'. Then when I type in 'domainABC.com', it also takes me to the same website (IP address 111.222.333), but the URL needs to show 'domainABC.com' instead of 'domain123.com'.
I guess I will need to redirect one of the two domains to the website, but how can I stop the URL changes the domain name?
I am not sure if I can just modify .htaccess to achieve above or if I also need to change the DNS, etc. to make this work.
Please help and many thanks
It depends on your setup and your server permissions.
A nice way will be to change the docroot in the apache or nginx config.
If you don't have permissions to edit these configs, you can create a symbolic links so that the public folder of domain2 points to the public folder of domain1

URL Canonocalization with w2 instead of www?

Recently while scrolling around the internet I've found a few websites that have w2 at the beginning of the URL instead of www. I'm not really sure of what the purpose of using this form of canonicalization may serve, other than just to be different. But after seeing that the Vatican's website also has it now, I'm starting to think it may actually have a functional purpose.
The Vatican's website has a lot of interesting redirects, but for me at least they all end up going back to w2.vatican.va as the base URL.
www.vatican.va redirects back there, google redirects there although it was indexed with the www.
So what is the purpose of using w2 instead of www?
The w2 is a subdomain, just as www is actually a subdomain. vatican.va is the top-level domain.
There are many uses for subdomains that usually come at the discretion of the developers, engineers, or administrators of a web site.
This is why sometimes you will see websites without the www (e.g. https://example.com). They have chosen to exclude the www subdomain. Most will pick one version to be their canonical and redirect the other to it.
In the example you provided, they chose to make their primary subdomain w2.vatican.va at some point and are redirecting (likely older) links from the www.vatican.va to the new one.
Additionally, the w2 domain may indicate that the web server is using IBM's CICS Transaction Server. The w2 may be it's default listener and the server administrators did not choose to change it.

Use htaccess mod_rewrite to hide domain name

I've read lots about what can be done with mod_rewrite but I haven't found one to solve my problem. Maybe it can't be done?
I have a sub-domain on my primary domain that I have a customer direct user to to use one of my programs. The customer doesn't want his customers to see that that are on my domain and he doesn't want to use an iframe.
So, is it possible for the user to only see www.subdomain/program.php instead of www.subdomain.mydomain.com/program.php?
If you want the browser to show www.subdomain/program.php in its location bar, you need to register the www.subdomain domain name. There is no way to remove bits of the domain name using anything in the htaccess file. For example, if you've registered example.com and you have a server at foo.example.com, and you want to be able to go to http://foo/some/path/index.html, you're out of luck because the browser is going to attempt to do a DNS lookup of foo and it will most likely fail unless there happens to be a "foo" server under the DNS search domain. Browsers put a great deal of effort to prevent spoofing of the domain name, since it would be really bad if I was able to spoof my website to show the domain of a bank in a browser's location bar while actually visiting an entirely different website.

redirect non existence url to folder

i am a user, and i type: www.japsomething.com, that url doesn't exist however there is a folder called "something" and i want this url to point to that folder?
do i need to purchase the domain name for this to work or i can use .htaccess?
i still would like to preserve the url. so this means, even though i am coming from
www.japsomething.com the url should still say www.japsomething.com and when i click anything on the site it should say www.japsomething.com/anything/
another question is, how can i detect based on the users ip that i want to show them a spanish site, or an english site?
thanks for your responses.
do i need to purchase the domain name for this to work or i can use .htaccess?
You need to purchase the domain name, because otherwise when someone types: www.japsomething.com, their DNS is going to try to look that name up, and if you don't own that domain, the request is never going to reach your server, thus, your htaccess file is never even used. Because you don't own every domain that starts with "jap" and ends with ".com", you can't use htaccess to do this.
i still would like to preserve the url. so this means, even though i am coming from www.japsomething.com the url should still say www.japsomething.com and when i click anything on the site it should say www.japsomething.com/anything/
If you own the "japsomething.com" domain, you simply point it to the server and directory that contains all the content, and then be done with it. No htaccess trickery is involved here. If you went out and bought the "japsomethingelse.com" domain, simply point it to the directory that serves that.
another question is, how can i detect based on the users ip that i want to show them a spanish site, or an english site?
See mod_geoip2 for downloads and examples.

.htaccess: Point Secondary Domain to Primary's Subdirectory

I have two domains on a VPS server, the primary "domain1.net" and the secondary "domain2.com". The website I have currently set up for domain2.com resides at domain1.net/subd1/subd2. I'm trying to create a rewrite rule for my .htaccess file so that whenever someone visits the site "domain2.com", "domain2.com/index.php", it grabs the page from "domain1.net/subd1/subd2", "domain1.net/subd1/subd2/index.php". I would like to do this while keeping "domain2.com" intact in the web address, instead of moreover redirecting it, and have all images/links appear from domain2.com.
From my understanding, it seems .htaccess's rewrite rule would be able to do such a thing, I just haven't figured out how the syntax would work. However, if there's a superior alternate method, I wouldn't be opposed to hearing it.
I appreciate anyone's help on this issue.

Resources