Only masking forward can surf the domain - masking

I have 2 domains let's say example.com and example.mynetwork.com
I am using parallels plesk webserver for main domain cpanel for subdomain
The subdomain example forward with masking to example.com can I make the website only work at example.mynetwork.com and if anyone visit the website example.com he redirect to example.mynetwork.com?

You can reach transparent redirect(or masking as you said) with frames, place following HTML code into index.html on example.mynetwork.com:
<FRAMESET>
<FRAME SRC="http://example.com/" NORESIZE>
<NOFRAMES>
Your browser does not support frames.
</NOFRAMES>
</FRAMESET>
In case of simple redirect:
Here simple index.php which redirects visitors to http://example.mynetwork.com
<?php
header("Location: http://example.mynetwork.com/");
die();
Place this file into /httpdocs of example.com

Related

.htaccess re-write works but I want to block domain from displaying origin. IPTables

I have setup the .htaccess file to rewrite anyone unwanted domains pointing to my VPS - There is only one domain left that gets mod-rewritten. I want to completly block this Domain from even accessing my origin IP address so I need help with the IP Tables - and how to stop targetdomain.com linking to my site!
Can anyone tell me what needs to be done on the Origin Server to deny access and forwarding from the target domain!
You can't stop someone else from having a DNS entry pointing to your server, but you could create a VirtualHost for that domain name, and configure that VirtualHost to always serve an error page for any URL. You mentioned iptables, but iptables doesn't deal with domain names -- you won't be able to use it to block a domain name.
Here's a very simple VirtualHost configuration you might put in your Apache config files:
<VirtualHost *:80>
DocumentRoot "/path/to/some/folder"
# You can only have one ServerName which is the main domain that
# you want to block, but if you have additional domains to block,
# you can add them with ServerAlias directives.
ServerName baddomain.com
ServerAlias another.baddomain.com
# This redirects all requests on this domain to index.html, so
# that visitors will see your message no matter what path they
# go to.
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/index.html
RewriteRule ^ /index.html [R=302]
</VirtualHost>
Now, inside the folder /path/to/some/folder (which you should replace with an actual folder path on your server), just create an index.html file with whatever message you want to show to anyone who visits this domain.
Example:
<!doctype html>
<html>
<head>
<title>Blocked domain</title>
</head>
<body>
<h1>Blocked domain</h1>
<p>The domain name you tried to connect to is blocked.</p>
</body>
</html>
Alternatively, you could have it redirect them to another website or whatever else -- read up on mod_alias or mod_rewrite for info on how to do this.

Redirect sub domains to non-www https

Hi we have developed a web app in laravel. Now we have two sub domains:
Devpanel.example.com
Panel.example.com
We want to make sure that we redirect www and http traffic to https and non www. Example:
Http:// panel. example. com to https:// panel. example. com
Http:// www. panel. example .com to https:// panel. example .com
Also any subpages shall be moved as an example http:// panel. example. com/users shall go to https:// panel. example. com/users and http:// www. panel .example .com/users shall go to https:// panel. example .com/users
If we are logged in to the app of course it should redirect us to the logged in state for all above scenarios.
Since this app is done in laravel it appends index.php in the URL when http is redirected to https. How can we make sure to remove this?
Any help on the above would be amazing.
You can edit the web.php file
if (env('APP_ENV') === 'production') {
URL::forceSchema('https');}
add the code above at the top To force on all pages.

Drupal Domain Redirection

We have two domains: www.example.com and www.example.org. Both point to the same site. But, we'd like everything to point to .org. We are running Drupal on a LAMP server hosted by Media Temple.
We have now started to have problems because our .com SSL cert expired, so anybody who goes to the .com site routinely gets scary messages in Chrome, etc.
How can we make it so that if somebody goes to https://www.example.com in google, they get nicely directed to http://www.example.org?
You can do this multiple ways.
.htaccess
RewriteEngine On
Redirect 301 / https://www.exmaple.org
In a PHP file
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://www.example.org");
header("Connection: close");
You can try this module :
https://www.drupal.org/project/domain_301_redirect
This is the domain that all other domains that point to this site will be 301 redirected to. This value should also include the scheme (http or https)
I Hope help you!

Apache Redirect domain.com/dir/slug to sub.domain.com/dir/slug silently without .htaccess

I'm having the darndest time trying to figure this out.
I have a site on a legacy system which will not permit me to alter the .htaccess file at domain.com. I have moved part of this site to a WordPress install located at sub.domain.com. I have to make the URL domain.com/dir/ redirect silently to sub.domain.com/dir/. How can I go about this? I can edit the Apache config files for both domain.com and sub.domain.com, and the .htaccess for sub.domain.com, but not the .htaccess for domain.com
Thanks!
Just add the redirect into the apache config files. In the virtualhost for domain.com:
Redirect 301 / http://sub.domain.com/
If by "silently" (not sure what that's supposed to mean since redirects are involve the browser sending a new request), I'm guessing you want to reverse proxy? Then you'd need to make sure mod_proxy is loaded, then do:
ProxyPass / http://sub.domain.com/

Apache: How can i redirect all sites on the server to an URL?

I have a VPS based Centos/cPanel-WHM. I wanna redirect all sites (including all pages & subdomains) on the server to one URL. How can i do this?
create .htaccess file in every website DocumentRoot dir which you want to redirect
# This allows you to redirect your entire website to any other domain
Redirect 301 / http://exampledomain-redirect.com/
At webserver layer (change the .htaccess), you could issue 301 redirects for any requests to your sites to new URL
OR
you could inject javascript (through your web layer) or your code layout framework OR manually
at the head of the page to complete a redirect.
OR
if your domains point to different hosting.. you could upate their NS to point to your new location and do 1 OR 2
.htaccess is the best way, Otherwise change the document root for each site.