Answered by
Oliver Hall
Configuring a 302 redirect in Apache is accomplished through the .htaccess file or within the server configuration files (httpd.conf or apache2.conf), depending on your hosting setup. A 302 redirect indicates to browsers and search engines that a resource has temporarily moved to a new location. This type of redirect is useful during site maintenance or when pages are temporarily relocated.
Access Your Configuration File:
Locate and open your .htaccess file using a text editor. If you have access rights, you might alternatively modify the main Apache configuration file usually named httpd.conf or apache2.conf.
Write the Redirect Rule:
You can implement a 302 redirect by adding the following line to your .htaccess file:
Redirect 302 /old-page.html /new-page.html
In this example, accessing http://yourdomain.com/old-page.html would temporarily redirect visitors to http://yourdomain.com/new-page.html.
Restart Apache: To make the changes effective, restart the Apache server. You can typically do this via a command in the terminal, such as:
sudo service apache2 restart
or
sudo systemctl restart httpd
depending on your system’s configuration.