Web Server

Redirect Single URL with Htaccess

Sometimes you want to change some of your URL. For example you renamed your old html file. Or you have removed some of your old files and you want to redirect them to a new URL.

But maybe other websites have linked to your old URL. You can’t contact them to change the URL, or you are too lazy to contact them, or maybe there are just so many backlinks pointed to the old URL so it is quite hard to change them all.

To avoid losing link juice from other websites, we must redirect the old URL to the new URL, with permanent redirection.

To do the redirection, we can use htaccess. And here is how to redirect a single URL (without using regular expression, so this will be faster), using .htaccess

You can add this line to your .htaccess file

RedirectPermanent /old-file.html /new-file.html

And now all traffic to old URL will be redirected to the new URL. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *