logo
Page Affairs

Editing and Web Design

Redirecting Web Pages

If you find it necessary to delete a page from your website, or if you need to move the location of your page and perhaps change its name too, there is a problem: there may be links all over the web to the page and its old location. For example, if someone finds a link to your old page in Google and clicks it, they will get an error message—such as “Page not Found”—which is not good for your visitors or your site.

Fortunately, there’s an easy way to does with this. You can set up a “redirect”, which determines a new page for your visitors to land on instead. This could either be the new version of the page at its new location, or at least a page explaining that the page has now been removed, and listing some other things the visitor might like to explore on your site.

Setting UP a .htaccess File

Assuming your web server is running Apache, you can easily set up your redirect(s) either by creating a .htaccess file in the root folder of your site, or by editing an existing .htaccess. (It’s likely that there is already one there, even if it’s empty.

The trick is to gain access to that .htaccess file—which isn’t always totally straightforward. Because this file begins with a dot, it may not show up in some code editors or on some systems. so you firstly need to work out the best way for you to access this file. I’ve already provided some tips on how to access your .htaccess file.

What to Put inside the .htaccess File

OK, let’s assume that http://mysite.com/folder/oldpage.html is the address of the old page that you are deleting, and that http://mysite.com/directory/newpage.html is the address of the new page.

In your .htaccess, you can place the following code:

Redirect 301 /folder/oldpage.html /directory/newpage.html

And that’s it! Now, if anyone clicks on a link to the old page, their browser will be directed to the new page.

Of course, if there is no new page to replace the old one, then try to direct users to something useful and related on your site, or at least a page explaining that the page is now gone, but offering links to other pages that might be of use.

Legacy Comments

© Page Affairs, 2008–2024