• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How To Configure Apache to Use Custom Error Pages and URL Redirection on centos 7.5

  • 00:42 yum install httpd -y
  • 00:59 systemctl start httpd
  • 01:20 cd /var/www/html/
  • 02:48 systemctl restart httpd
  • 03:23 vim test.conf
  • 03:54 systemctl restart httpd
  • 04:45 vim test.conf
  • 05:39 systemctl restart httpd
  • 06:20 cd /var/www/html/
  • 07:56 systemctl restart httpd
{{postValue.id}}

Configuring Apache to Use Custom Error Pages and URL Redirection on centos 7.5

Apache is the most popular web server in the world. It is well-supported, feature-rich, and flexible. When designing your web pages, it is often helpful to customize every piece of content that your users will see. This tutorial covers the installation procedure of Apache to Custom Error Pages and URL Redirection on centos 7.5.

Installation

Let' s install apache web server package by using yum command.

[root@linuxhlep ~]# yum install httpd -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirror.nbrc.ac.in
 * updates: mirror.nbrc.ac.in
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-88.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================
 Package               Arch                   Version                             Repository            Size
=============================================================================================================
Installing:
 httpd                 x86_64                 2.4.6-88.el7.centos                 base                 2.7 M
.
.
.
Running transaction test
Transaction test succeeded
Running transaction
  Installing : httpd-2.4.6-88.el7.centos.x86_64                                                          1/1 
  Verifying  : httpd-2.4.6-88.el7.centos.x86_64                                                          1/1 

Installed:
  httpd.x86_64 0:2.4.6-88.el7.centos                                                                         

Complete!

Start and enable the apache service by using following command.

[root@linuxhlep ~]# systemctl start httpd
[root@linuxhlep ~]# systemctl enable httpd.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

Create html file for document root in .html format

[root@linuxhlep ~]# cd /var/www/html/
[root@linuxhlep html]# vim index.html
<h1> Welcome to linuxhelp user’s </h1>

Change ownership and give Execute permission for this file.

[root@linuxhlep html]# chown -R apache.apache index.html 
[root@linuxhlep html]# chmod -R 775 index.html

Create the name based virtual host like this.so, go to the confguration location and create test.conf file.

[root@linuxhlep html]# cd /etc/httpd/conf.d/
[root@linuxhlep conf.d]# vim test.conf
<virtualhost *:80>
servername linuxhelp1.com
Documentroot /var/www/html/
</virtualhost>

Once restart the service for changes

[root@linuxhlep conf.d]# systemctl restart httpd

After restarting the service Open your web browser and navigate to the URLs Domain name or IP address. You should see the sample demo pages which we created earlier. 1

How To Configure Apache URL redirection

Create a following apache redirect rules on configureation file,

 [root@linuxhlep conf.d]# vim test.conf 
<virtualhost *:80>
servername linuxhelp1.com
Documentroot /var/www/html/
Redirect / "https://www.linuxhelp.com/"
</virtualhost>

Once restart the service for changes

 [root@linuxhlep conf.d]# systemctl restart httpd

After restaring the service Open your web browser and navigate to the URLs Domain name or IP address . 2 Now url redirection successfully configured.

How to Configure Apache to Use Custom 404 Error Page

Go to the Document root, already download 403 and 404 error image download to the following location,

[root@linuxhelp conf.d]# cd /var/www/html/
 [root@linuxhelp html]# ll
-rwxrwxr-x 1 apache apache 5606 Apr  3 01:15 403.jpg
-rwxrwxr-x 1 apache apache 9812 Apr  3 01:15 404.png
-rwxrwxr-x 1 apache apache   31 Apr  3 01:07 index.html

Edit the configuration file,

[root@linuxhlep conf.d]# vim test.conf 
<virtualhost *:80>
servername linuxhelp1.com
Documentroot /var/www/html/
#Redirect / "http://www.google.com"
ErrorDocument 404 "http://linuxhelp1.com/404.jpg"
</virtualhost>

Once restart the service for changes

[root@linuxhlep conf.d]# systemctl restart httpd

After restaring the service Open your web browser and navigate to the rong URLs Domanin name/somthing or Ip address/somthing.
3 Now 404 Error Pages successfully customized.

How To Configure Apache to Use Custom 403 Error Page

Go to html location create an one directoy

[root@linuxhlep conf.d]# cd /var/www/html/
[root@linuxhlep html]# mkdir test

Open the configuration file. Here, give the permission to access the directory my local machine only.

[root@linuxhlep html]# vim /etc/httpd/conf.d/test.conf
<virtualhost *:80>
servername linuxhelp1.com
Documentroot /var/www/html/
#Redirect / "http://www.google.com"
ErrorDocument 404 "http://linuxhelp1.com/404.jpg"
ErrorDocument 403 "http://linuxhelp1.com/403.jpg"
<Directory /var/www/html/pirai>
AllowOverride None
Require ip 127.0.0.1
</Directory>
</virtualhost>

Once restart the service for changes

 [root@linuxhlep conf.d]# systemctl restart httpd

After restaring the service Open your other machine web browser and navigate to the URLs Domain name/test or IP address/test. 4 Now 403 Error Pages successfully Customized.

With this, the method to Configure Apache to Custom Error Pages and URL Redirection on centos 7.5 comes to an end

Tags:
jacob
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What does 200, 403 & 503 HTTP error code mean?

A

* 200 – content found and served OK

* 403 – tried to access restricted file/folder

* 503 – the server is too busy to serve the request and in another word – service unavailable.

Q

How to redirect a WordPress site to another URL?

A

Select a site to redirect from this screen. After you select a site, enter the new domain or address where you want your WordPress.com traffic to be redirected. Type the URL of the destination site into the blank field, and click the blue button that says Go.

Q

What is a custom 404 page?

A

Create custom 404 pages. A 404 page is what a user sees when they try to reach a non-existent page on your site (because they've clicked on a broken link, the page has been deleted, or they've mistyped a URL).

Q

What is a redirection attack?

A

2320 URL Redirection Attack. Session stealing based on URL redirection or forwarding is a weakness, which in most cases requires the victims interaction (social engineering). The conduction of such an attack is relatively simple. The web application remembers the URL, which was requested from a client web browser.

Q

What is URL redirection vulnerability?

A

Description: Open redirection (reflected) Open redirection vulnerabilities arise when an application incorporates user-controllable data into the target of a redirection in an unsafe way. An attacker can construct a URL within the application that causes a redirection to an arbitrary external domain.

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Elijah ?
Remote Desktop Connection Has Stopped Working

When accessing my remote machine server using remote desktop on a windows machine I am getting this error

forum (1)

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.