Unable to show siteA's content at siteB by domain masking - .htaccess

I have a domain www.siteA.com, which uses Joomla, while the domain www.siteB.com is empty.
I would like to show the content of the domain www.siteA.com at www.siteB.com.
I tried to solve the problem first by making a domain redirection by .htaccess, but I could not show SiteA's content at SiteB.
How can you show the contents of mysiteA.com at mysiteB.com by domain masking in .htaccess?

You really should be doing this by CNAME-ing the domain, but if you really want to use .htaccess you can do what #Unkwntech suggests
Edit: It would just look like
www.siteB.com CNAME www.siteA.com
Whichever way you do it (CNAME or htaccess) you're probably going to get an SEO penalty for duplicate content.

RewriteEngine On
RewriteRule ^.*$ http://www.siteA.tld/$1 [NC]
This should rewrite every request to siteA.

Related

Fake subdomain for different users while still browsing same folder structure

I'd like to create fake subdomains for different users for more vanity, and to make the user (in this case a company) feel they are in a more isolated environment.
For the sake of maintainability, it's important for me that all users still browse the same files, to avoid having to update files for every single user that exists when updating the code.
My website has one public part at root, let's say www.example.com. I'd like to be able to fake the following kind of subdomains:
user1.example.com
The true URL would be www.example.com/member/?user=user1. I'd like for the folder structure to follow the same pattern. www.example.com/member/settings/?user=user1 would appear as user1.example.com/settings/ and so on.
I assume this would best be achieved with .htaccess, no?.
What is the proper .htaccess code for this?
Thank you!
based on the information you've provided here's a bit of .htaccess not tested but might do the job.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?example.com$ [NC]
RewriteCond %{QUERY_STRING} ^user=(.*)$
RewriteRule ^(.*)$ http://%1.example.com/$2? [R=302,L]
Once you find it working fine, replace 302 to 301
Note: It's important to note that you'll need to add a subdomain wildcard
In the end, this was super easy to solve! It wasn't solved the way I first expected though, using .htaccess. I solved it with something called wildcard subdomain.
When you register a new subdomain, enter * in the domain prefix, such as *.example.com. A folder for the wildcard subdomain will be created on your server, such as _wildcard_.example.com. Whenever you access site1.example.com, fakesub.example.com etc, the browser of the visitor will read the files in the wildcard.example.com folder.
The beauty of it all is that if I create a certain subdomain that I want to use, for example forum.example.com, this real subdomain will have priority over the wildcard subdomain, and files will be fetched from the folder for this subdomain, as opposed to from the wildcard subdomain folder.
I use PHP and need to know the subdomain to fetch the appropriate database for the current user. To do this, I use the following code:
$subdomain = explode('.', $_SERVER['HTTP_HOST'])[0]
With a wildcard SSL cert I have all of these subdomains secure.

How to redirect entire domain to new domain except homepage via htaccess

So I have found some questions that are close to what I need, but I haven't found exactly what I'm looking for.
While I've worked with htaccess files in the past, it's pretty much been just copying and pasting code that is proven to work, or just doing simple 301 redirects. To be honest, I get pretty confused when looking at htaccess rewrite rules, so unfortunately are not going to be able to do from scratch. So I'm really hoping there is someone kind enough to provide a code example just using placeholder domain names.
Here is my situation. I'm doing work for a company who has split up into different divisions (4). So they want to take the site on their current domain, move it to a different domain. Then put up a simple html splash page on the old domain that provides links to the 4 different sites they will have (one of those being what was the old site on a new domain).
So I need to redirect everything from olddomain.com to newdomain.com with the exception of the homepage. Not sure if this matters, but site that was on the old domain was a WordPress site so technically is index.php. But the new site/splash page is named index.html.
Thanks in advance!
So I need to redirect everything from olddomain.com to newdomain.com with the exception of the homepage.
You can use this rule in the site root .htaccess of olddomain.com:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?olddomain\.com$ [NC]
RewriteCond %{REQUEST_URI} !/(css|js|images)/ [NC]
RewriteRule . http://newdomain.com%{REQUEST_URI} [L,NE,R=301]
RewriteRule . will match everything except the home page just make sure this rule is the first rule in your .htaccess.

Another .htaccess redirect case

I have a site where mydomain.com and mydomain.com/frontpage serves the exact same content.
Socalled SEO experts tell me it is very bad to have the same content on different addresses. Google will cast upon me a terrible fate.
So I thought fine, I'll just redirect mydomain.com to mydomain.com/frontpage, but I'm failing miserably. I just can't wrap my head around htaccess commands.
I need to have visitors who visits mydomain.com or www.mydomain.com to be redirected to www.mydomain.com/frontpage in a way to that it becomes visible in the browser address field.
BUT nothing else must be redirected.
For example, www.mydomain.com/anotherpage must still be there.
My .htaccess is already full of a lot of rewrite rules that redirects all of these user-friendly addresses to the real urls (index.php?pageid=341) etc. So I'm thinking I would first redirect mydomain.com to mydomain.com/frontpage and then let another RewriteRule later make sure that mydomain.com/frontpage actually points to index.php?pageid=341.
But mydomain.com => mydomain.com/frontpage must be a visible redirect, while all the other rewrite rules are hidden from the user.
How does the Redirect or RedirectMatch or RewriteRule look like, that redirects visitors from www.mydomain.com to www.mydomain.com/frontpage while keeping other addresses like e.g. www.mydomain.com/anotherpage ?
Thanks.
You can insert this new rule just below RewriteEngine On line:
RewriteRule ^/?$ /frontpage [L,R=301]

Best way to change domain names

I have a blog which i get about 1200 visits a month lets say the blog domain name is.
exampleblog.com
What i want to do is complete change the domain name to say.
iamsam.com
What is the correct way to do this should i map the domain iamsam.com to my exampleblog.com account on my hosting then put a 301 redirect in the htaccess to redirect traffic to the correct domain ie.
Options +FollowSymlinks
rewritecond %{http_host} ^exampleblog.com [nc]
rewriterule ^(.*)$ http://www.iamsam.com/$1 [r=301,nc]
Is this the correct way to do this???
Can someone advise me thanks
Yes, that is exactly the way to do it, assuming the URL scheme for the new domain is exactly the same as the old domain.
You might also want to capture users that use the old address and display some sort of notification on the new website, so that they'll notice the change and update their bookmarks.

Display content as root from subdomain

I have a site running on a subdomain of new.site.com and I want to be able to just put something in the .htaccess file that will display the subdomain's content as if it was in the root.
Where the site is: new.site.com
The url that I want to use: site.com
Basically what I want to do is just not move the files from the subdomain to the root of my server.
Try using a domain pointer.
EDIT:
Not sure why my answer was downed. Let me elaborate a little more.
I do this myself on my websites. In my hosting company's control panel, I have the option to create domain pointers. What this does is set a domain to use the website of another domain.
Actually found this that works incase anyone was wondering:
RewriteEngine on
RewriteBase /
RewriteRule ^$ /subdomain/ [L]

Resources