2-

---

redirect pages on an apache/centos web server

[root@server ~]# vi /etc/httpd/conf/httpd.conf

<VirtualHost *:80>    Servername mail.worldcm.net    RedirectTemp /index.html https://mail.worldcm.net:20000/    RedirectPermanent /welcomepage https://mail.worldcm.net:20000/ </VirtualHost>

<VirtualHost *:80>    Servername domain1.com    Redirect /AboutUs/Founders http://www.domain2.com/about-us-founders/    Redirect /AboutUs/         http://www.domain2.com/about-us/    Redirect /index.html       http://www.domain2.com/page12345/    RedirectMatch ^            http://www.domain2.com/page12345/ </VirtualHost>

# Redirect

<VirtualHost *:80>

   Servername mail.worldcm.net

#   Redirect /mailreports/ http://mail.world.net/awstats/awstats.pl

   RedirectPermanent /mailreports http://mail.world.net/awstats/awstats.pl

  RedirectTemp /index.html https://mail.world.net:20000/

  RedirectPermanent /welcomepage https://mail.world.net:20000/

</VirtualHost>

Auto Redirect HTTP to HTTPS

You can simply set Redirect Permanent Rule

<VirtualHost *:80>

<Location />

Redirect permanent / https://www.worldcm.net/

</Location>

</VirtualHost>

 # Virtual

<VirtualHost *:80>

     DocumentRoot /var/www/html

     ServerName mail.worldcm.net

  #   ServerAlias  mail.worldcm.net

   #  ErrorLog /var/www/example.com/error.log

    # CustomLog /var/www/example.com/requests.log

</VirtualHost>

<VirtualHost *:80>

     DocumentRoot /var/www/html/new

     ServerName mail.worldcm.net/new

  #   ServerAlias example.com

   #  ErrorLog /var/www/example.com/error.log

    # CustomLog /var/www/example.com/requests.log

</VirtualHost>

##################################################################################################

SUB Donaim - CacTi

cat <<EOF | sudo tee -a /etc/httpd/conf.d/cacti.conf <VirtualHost *:80> ServerAdmin admin@example.com DocumentRoot /var/www/html/ ServerName cacti.example.com ServerAlias www.cacti.example.com <Directory /var/www/html/cacti/> Options FollowSymLinks AllowOverride All Order allow,deny allow from all </Directory> ErrorLog /var/log/httpd/cacti.example.com-error_log CustomLog /var/log/httpd/cacti.example.com-access_log common </VirtualHost> EOF

Port-Based Virtualhost - webpage

mydomain.com:80  --- opens var/www1 mydomain.com:81  --- opens var/ww2 mydomain.com:82  --- opens var/www3

> netstat -tulpn | less tcp        0      0 :::80       :::*      LISTEN      6840/httpd tcp        0      0 :::81       :::*      LISTEN      6840/httpd tcp        0      0 :::82       :::*      LISTEN      6840/httpd

[root@server ~]# vi /etc/httpd/conf/httpd.conf

Listen 80 Listen 81 Listen 82  # Listen for virtual host requests on all IP addresses NameVirtualHost *:80  <VirtualHost *:80> DocumentRoot /var/www1 ServerName www.example1.com </VirtualHost>  NameVirtualHost *:81 <VirtualHost *:81> DocumentRoot /var/www2 ServerName www.example2.org </VirtualHost>   NameVirtualHost *:82 <VirtualHost *:82> DocumentRoot /var/www3 ServerName www.example3.org </VirtualHost>

###############################################################

----------------------------

need to have a webpage with the name for example www.abc.com to redirect to www.xyz.com however keeping www.abc.com in the URL bar.

vim /etc/httpd/conf/httpd.conf   <VirtualHost 10.10.10.11>     ServerName  abc.com     ServerAlias abc.com     Redirect / www.xyz.com </VirtualHost>  service httpd reload

From here when I access www.abc.com it redirects fine to www.xyz.com however www.xyz.com show in the URL Bar instead ofwww.abc.com. I did some googling and noticed this site: http://www.ontwerps.nl/domain-redire...th-url-masking

So I changed the code to:

Code:

vim /etc/httpd/conf/httpd.conf   <VirtualHost 10.10.10.11>     ServerName  abc.com     ServerAlias abc.com     RewriteEngine On     RedirectMatch 301 (.*)$ www.xyz.com$1 </VirtualHost>

--------

Pound : URL Redirect2015/01/31

 

 

[1]

This is the Redirect settings from URL matching.

This example based on the environment like follows.

       | --------+--------------------------------------------------------------------         |         +-------------------+--------------------+--------------------+         |10.0.0.30          |10.0.0.51           |10.0.0.52           |10.0.0.53  +------+-----+     +-------+------+     +-------+------+     +-------+------+  |  Frontend  |     |   Backend#1  |     |   Backend#2  |     |   Backend#3  |  |   Pound    |     |  Web Server  |     |  Web Server  |     |  Web Server  |  +------------+     +--------------+     +--------------+     +--------------+ 

For example, Configure Pound like that 

HTTP connections to dlp.srv.world are forwarded to Backend#1,

HTTP connections to dlp.virtual.host are forwarded to Backend#2,

HTTP connections to others except above are forwarded to Backend#3.

Configure Pound.

[root@dlp ~]# mv /etc/pound.cfg /etc/pound.cfg.org 

[root@dlp ~]# vi /etc/pound.cfg

User "pound" Group "pound" LogLevel 3 LogFacility local1 Alive 30  ListenHTTP     Address 0.0.0.0     Port 80 End  Service

    # define for dlp.srv.world

   HeadRequire "Host: .*dlp.srv.world"     BackEnd         Address  10.0.0.51         Port     80         Priority 5     End End  Service

    # define for dlp.virtual.host

   HeadRequire "Host: .*dlp.virtual.host"     BackEnd         Address  10.0.0.52         Port     80         Priority 5     End End  Service

    # define for others

   HeadRequire "Host: .*"     BackEnd         Address  10.0.0.53         Port     80         Priority 5     End End 

[root@dlp ~]# /etc/rc.d/init.d/pound restart 

Stopping Pound: [ OK ]

Starting Pound: starting...

[ OK ]

[2]

Make sure all works fine to access to the frontend server from a Client with HTTP like follows.

-------------------