Domain Cloaking using HTACCESS or PHP - php

I currently have a website which allows our clients with other domains to redirect their domains to our website and use some of our features.
My problem is our clients dont want their clients and customers know that they are being redirected to another site.
So my question is, Is it possible to cloaking (using .HTACCESS or PHP) my domain such that the user will enter our clients' domain and be redirected to our site without the browser showing that they have been redirected?
Thanks

No.
Your customers will have to create A or CNAME DNS records pointing to your servers (CNAME is preferred so you can change the IP without your customers changing anything).
Then you need to configure your webserver to handle requests for their domains (ServerAlias their.domain in the VirtualHost).

Why not? Just google php proxy. This should do the trick for you.

Related

Subdomains redirection

With my current PHP knowledge, I know how to create a subdomain automatically via Plesk api when a user is created on my site. I can then redirect the user.example.com to example.com/user via htaccess.
My question that I cannot figure out how to do, is how to redirect but also keep user.example.com in the navigation bar, not the example.com/user ?
I own a dedicated hosting environment so I have access to change pretty much any setting that I like.
Here are some suggestions:
Don't use .htaccess for this. A very common use of .htaccess is to redirect all requests to a central file (generally index.php).
In order to allow dynamic subdomains you need to make sure your virtual host is configured properly for that.
And in order to redirect to the subdomain url you can use the built-in php function header.
Example:
header('Location: '.$subdomainUrl);

Laravel application with subdomains that can be linked to other domains via CNAME

I'm trying to create an application architecture similar to that of Shopify's.
I am running this application from Forge and I've set up the necessary configuration for wildcard DNS to work.
At the moment people can sign up to my Laravel Spark app and then a subdomain will be created dynamically for them at:
Route::group(['domain' => '{company}.app.com'], function () {
Route::get('/', 'SubdomainController#index');
});
So if they register an account and set the company name as Company then they will have a subdomain created at company.app.com. This subdomain returns a view with data related to their account (It pretty much returns a custom website for my user).
I'd like to give users the ability to mirror their site at company.app.com to their own domain address. I have tried setting up a mask within GoDaddy on a spare domain I have to test this however it doesn't seem to work :( I get this error in the console:
Refused to display 'http://company.app.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
So I'm guessing this is definitely not the right way to do it.
After this happened I looked at how other companies managed this and it looks like they create an A record and CNAME that points to the root of their app. Shopify's guide explains that they add their IP as an A record and then the CNAME is set as the shops.myshopify.com domain.
So now I'm left wondering how I can point requests in the right direction when they land on my app. So for example if traffic hits random.com and it has an A record that is equal to my servers IP, plus a CNAME of app.com, then how do I handle the request and redirect it to the correct subdomain whilst keeping the user on their custom domain?
Thanks, Nick
It's much easier than that. Your server is setting the X-Frame-Options header to SAMEORIGIN which means content from your site can only be rendered within a frame if that frame is on your domain.
You either get rid of that totally, so anyone can frame your content on any site, or you save your customers domains and do some sort of database lookup on the fly, or configure some sort of specific url for them to use for content linking which proxies to their directory on your server and has a part of the url which you can capture as a variable to use in your server config. Then you set your header to allow from their domain only.
So embed.myapp.com/example.com could serve the content from example.myapp.com and add the header
X-Frame-Options: ALLOW-FROM https://example.com/

HTTP request on hosted PHP files

I'm currently making an app with React Native and I need to perform some HTTP requests on PHP files, that are hosted on a CPanel file manager.
So I need to put the link in my request, but the problem is that it includes a security token when I sign-in on the website to see these files.
As it is changing every time, I guess that I need to get this token in my app and use it to perform the requests.
I browsed the documentation of CPanel to find a way but I can't figure it out.
Thanks in advance for your help
The easiest method without domain-pointing is access by hosting IP and your username account on that hosting. Example:
http://XXX.XXX.XXX.XXX/~username/yourapifile.php
where XXX.XXX.XXX.XXX is your hosting IP and username is your username account (with ~ prefix).

Getting an original URL before redirection in PHP

I have a website (example.com) which will be a hub for redirection from several other domain (example.co.uk, example.org... etc etc). These addon domains are other third-party websites that doesn't belong to me. The redirection from other domains was setup by the other hosting provider using 301 method.
The question is: is it possible to get the URL of where the user was redirected from? $_SERVER['HTTP_REFERER'] definitely doesn't work over here.

Cookies available on different domains / htaccess forwarding

we are running an online portal which is available via different domains (e.g. example.de, example.at, example.ch) as well as variations of it (e.g. exam-ple.de) and payment for all countries is done via secure.example.com, so it is not possible to access cookies on secure.example.com which were set on example.de.
First question (not directly refering to cookies):
Is it possible to forward a user from exam-ple.de to example.de without loosing the referer information? Maybe with .htaccess?
Second question:
Is it "dirty" to store all cookie names in a configuration file and then pass all cookies via GET everytime the user gets forwarded to another domain name and reset the cookies? I can only think of this one solution to make cookies available on different domains... Or does anyone has a better solution for the problem?
Best regards,
Freddy
To answer your first question, assuming that you are using apache2 as the web server (you told about .htaccess) , I would suggest using mod_rewrite for redirecting the urls to a different domain. When using mod_rewrite you are enabled to set cookies
Also you can create a php script that forwards to your domains and sets the cookies. It might be called like www.yourdomain.com/forward.php?target=at&....

Categories