Jump to content

How to Apply 301 Redirects With Apache

From freem


A 301 redirect is a permanent redirect from one URL to another. This type of redirect is useful when you want to change the URL of a page, or when a page has moved to a new location.

Apache is a popular web server that can be used to implement 301 redirects. Here are the steps to apply 301 redirects with Apache:

1. Determine the old and new URLs: Before you can set up a 301 redirect, you need to know the old URL (the URL that needs to be redirected) and the new URL (the URL that the old URL should redirect to).

2. Connect to your server: You'll need to connect to your server to edit the Apache configuration file. You can use SSH or FTP to connect to your server.

3. Edit the Apache configuration file: The Apache configuration file is usually located at /etc/httpd/conf/httpd.conf or /etc/apache2/apache2.conf. You'll need to edit this file and add the following code to set up a 301 redirect:

``` Redirect 301 /old-url http://www.example.com/new-url ```

In this example, /old-url is the old URL that needs to be redirected, and http://www.example.com/new-url is the new URL that the old URL should redirect to.

4. Save the Apache configuration file: After you've added the code for the 301 redirect, save the Apache configuration file and exit.

5. Test the redirect: To make sure the redirect is working properly, enter the old URL in a web browser and see if it redirects to the new URL.

That's it! With these steps, you can easily set up a 301 redirect with Apache.