I am trying to allow customers to have multiple domains, but 301 them to their "permanent" domain for canonical reasons. I am getting some strange activity, and am positive it has to do with my syntax, however I don't know where the issue resides.
I have a main domain - let's call it permanent_site.com Note: I have an SSL installed and working for "permanent domain"
I have multiple non-permanent domains that I want to permanently redirect to the "permanent domain". Now lets say I have 2 non primary domains: non_p_domain1.com and non_p_domain2.com.
Should this not work?
<VirtualHost *:443>
ServerName non_p_domain1.com
ServerAlias non_p_domain2.com
Redirect 301 / https://permanent_site.com/
</VirtualHost>
<VirtualHost *:443>
ServerName permanent_site.com
DocumentRoot /path/to/html
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCertificateFile /path/to/ssl/permanent_site.com.crt
SSLCertificateKeyFile /path/to//ssl/permanent_site.com.key
SSLCertificateChainFile /path/to/ssl/permanent_site.com.ca.crt
</VirtualHost>
The whole point in doing it this way is to prevent someone from hitting https://non_p_domain1.com and being fed an "unsecure page". Instead, I want them redirected to the permanent domain before they hit the html directory that has all the .htaccess directives.
from hitting https://non_p_domain1.com and being fed an "unsecure page"
All the non-primary domains also need to have an SSL cert installed. By the sounds of it, they don't?
If not, then the client won't (or should not) connect to your server, so they never see the redirect.
Related
I would like to redirect wildcard subdomain to my actual domain.
like this (I already have error.example.com)
dsfas.example.com -> error.example.com
but I could not do this after hours of searching. Is there a solution to this.
I am using apache
You can do this by creating a “catch-all” Apache configuration and redirecting to the domain you specify.
Create an Apache configuration file with a name like zzz-catchall.conf (so that it’s the last file alphabetically in the directory) and paste this into the file:
<VirtualHost *:80>
ServerAdmin none#noaddy.net
DocumentRoot /var/www/catch/public
ServerName catch.example.com
ServerAlias *.example.com *.*
DirectoryIndex index.php index.html
ErrorLog ${APACHE_LOG_DIR}/catch-error.log
CustomLog ${APACHE_LOG_DIR}/catch-access.log combined
<Directory /var/www/catch/public>
Options FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
Be sure to change the domain names and directories accordingly.
In the /var/www/catch/public (or whatever) directory, you can set up a redirect a number of ways, but .htaccess would be simple enough:
Redirect 301 / https://error.example.com/
Ensure the virtual host configuration file is enabled, and reload Apache. That should get you going 👍🏻
we need our new dedicated IP address (and all future ones) to "point" to the same root directory of our VPS' "parent" domain (main domain with all business logic, where $_SERVER['host'] is detected to connect associated files etc. )
So, for example, domain.net (x.x.x.146) should show content of domain.com (x.x.x.170) etc
We have list of dedicated IPs, added to WHM. We have number of domain names, with those IPS as DNS A records. We have added those domains via cPanel to point to the same public_html..
But all the domains resolve to : cgi-sys/defaultwebpage.cgi with "SORRY! If you are the owner of this website, please contact your hosting provider:" error.
Any suggestions? This is supposed to be quite an easy task, but clearly - not so.
Thank you
Why do you need many IP address? one IP address should be enough for what you want to do.
Indeed HTTP/1.1 protocol is meant for this purpose: many different domains for one IP.
In your VPS you can use for example "Apache" as a Web server with this basic configuration:
ceate/edit on "/etc/apache2/sites-available/" example.com.conf :
<VirtualHost *:80>
DocumentRoot /home/user/pulic_html
ServerName example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
then create/edit example.org.conf:
<VirtualHost *:80>
ServerName example.org
Redirect permanent / http://example.com/
</VirtualHost>
and so on..
then to enable your configuration :
a2ensite example.com.conf example.org.conf
sudo service apache2 restart
If you still want to use many IPs you can install apache in every machine hosting the IP, then redirect to your main site/domain(http://example.com), as shown above. Otherwise, if your hosting provider allow, you can redirect your children domain to your parent domain from your provider website with GUI.
here is the solution. It is not ideal bot it looks like there's not much we can do, having cPanel/WHM installed.
<VirtualHost x.x.x.x:443>
ServerName domain.net
ServerAlias www.domain.net
DocumentRoot /home/user/public_html
#todo common contact mail
ServerAdmin support#domain.net
UseCanonicalName Off
<IfModule mod_suphp.c>
suPHP_UserGroup user user
</IfModule>
<IfModule ssl_module>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/domain.net/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.net/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/domain.net/chain.pem
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
</IfModule>
<IfModule headers_module>
RequestHeader set X-HTTPS 1
</IfModule>
</VirtualHost>
redirect from 80 to 443 set separately:
RewriteEngine On
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
I'm trying to set up a subdomain for on a client's web server. It's a CentOS server running Apache. So say the website is "example.com". I'm trying to create "bugs.example.com".
So far, I've added to the vhost.conf file the subdomain info:
<VirtualHost *:80>
ServerName bugs.example.com
ServerAlias bugs.example.com
DocumentRoot /var/www/www.bugs.example.com
<Directory "/var/www/www.bugs.example.com">
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I've added the server's IP address and the subdomain to /etc/hosts:
111.222.333.444 bugs.example.com
I've created the directory for the website files, and an index page at:
/var/www/www.bugs.example.com/index.html
Sadly, I still get a "Server not found" error when I go to bug.example.com. What am I missing here? The example.com domain name is registered through GoDaddy.com. Is there something that needs to be done there?
I have recently just set up a RHEL based server running two domains. However, I am having difficulty hitting both domains from the browser. My config is:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName domainA.com
ServerAlias domainA.com *.domainA.com
DocumentRoot /home/domainA/public_html
<Directory "/home/domainA/public_html">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName domainB.com
ServerAlias domainB.com *.domainB.com
DocumentRoot /home/domainB/public_html
<Directory "/home/domainB/public_html">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
The problem is when I navigate to domainA.com I hit the correct Virtualhost (which is fine), however when I navigate to domainB.com it displays the Apache Test page.
Edit
I have a Firewall between the webserver and the web. I tested the rules governing Domain A and Domain B.
Domain A reaches target and a status 200 is returned.
Domain B reaches target and a status 403 (permission denied) is returned
What you need to do is take a look at sites-enabled and sites-available.
Here's the first entry when Googling: http://www.debian-administration.org/articles/412
Looks reasonable and should help you integrate that.
The problem is that you need separate entries for all the sites you want to run on this apache2. Simple entries in your config file don't do it. Only the first works, the rest is more or less ignored. Creating separate entries with sites-enabled and sites-available is the way to go here.
So here's the scenario:
The domain I have is www.abc.com and I want to point it to (which belongs to another company).
Question: How would I use .htaccess to forward and mask the url so that it stays as www.abc.com?
In terms of security, is there any point in buying a digital certificate for www.abc.com?
You could uh, run it through a proxy, which will TOTALLY mask it.
You put this in your httpd.conf file, not the .htaccess:
<VirtualHost *:80>
ServerName www.abc.com
ServerAlias abc.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://site-you-want-2-show.com:80/
ProxyPassReverse / http://site-you-want-2-show.com:80/
<Location />
Allow from all
</Location>
</VirtualHost>
You can try with ProxyPreserveHost both On and Off, and testing if the images display properly and the addresses of objects show your domain instead.
WARNING: This is not legal if you do not have explicit permission from the company you are trying to show's website. Perhaps you can then just make your homepage an iFrame.
As for certificates: It can be done, see here: http://ssl-proxy.plz.re (short-url)
.htaccess files cannot "mask" a domain but could use a reverse proxy if the module is installed.
In most case, the "masked" website will refer to full urls and the "mask" will not work for long.
See what #mesh proposed.