Explore Replug’s New Free AI Tools – UTM Builder, Caption Generator & More (All For Free) - Try Now 🎉

How to Redirect a URL to Another URL?

Arslan Jadoon
6 minutes

Redirecting a URL to another destination is a fundamental skill in web development and online communication. Whether you’re rebranding a website, updating content, or optimizing user experience, the ability to seamlessly guide users from one web address to another is invaluable. 

In this guide, we’ll explore various methods and step-by-step instructions on how to effectively redirect URLs, ensuring your online presence remains agile and user-friendly.

What is a URL redirect?

A URL redirect is a way to send users from one URL to another. This can be done for a variety of reasons, such as:

  • To improve the user experience by sending users to a more relevant or up-to-date page.
  • To prevent broken links by redirecting users to a new page that has replaced the old one.
  • To track website traffic by redirecting users to a different page depending on where they came from.

2 main types of URL redirects:

There are two main types of URL redirects: 301 redirects and 302 redirects. 

A 301 redirect is a permanent redirect, which means that the old URL will no longer be used and all traffic should be directed to the new URL. 

A 302 redirect is a temporary redirect, which means that the old URL may be used again in the future.

URL redirects can be set up by website administrators or by using a third-party service.

Also read: How to Fix “ERR_TOO_MANY_REDIRECTS” Error: Step-by-Step Guide

How to redirect a URL to another URL?

Redirecting a URL to another URL can be done using various methods, depending on your specific needs and the technology stack you are using. 

Here are some common methods and steps for each:

  • HTTP Redirects (Status Codes 301 and 302)
  • Using JavaScript for Client-Side Redirect
  • Using Meta Refresh Tag (HTML Meta Tag)
  • Using Server-Side Scripting (e.g., PHP)
  • Using URL Rewrite Rules (Apache mod_rewrite or Nginx)
  • Using a Content Management System (CMS)
  • Using a URL shortener 

Now, let’s explain each of these methods step by step:

Link Management Made Easy

Your go to link management tool for CTAs, branded and bio links, QR Codes, tracking and retargeting.

Get Started for FREE!
link management made easy

Method 1: HTTP redirects (status codes 301 and 302)

Step 1: Open your web server configuration file (e.g., Apache’s “.htaccess” for Apache servers) or use a control panel like cPanel.

Step 2: Add the following line to redirect the old URL to the new URL:


Replace “/old-page.html” with the path to the old URL and http://example.com/new-page.html with the new destination URL.

Step 3: Save the configuration file.

Step 4: The 301 redirect informs search engines that the old URL has permanently moved to the new URL.

Method 2: Using JavaScript for client-side redirect

Step 1: Insert the following JavaScript code in the <head> section of your HTML document:


Replace “http://example.com/new-page.html” with the URL you want to redirect to.

Step 2: When a user accesses the old URL, they will be automatically redirected to the new URL.

Method 3: Using meta refresh tag (HTML meta tag)

Step 1: Insert the following HTML <meta> tag in the <head> section of your HTML document:


Replace “http://example.com/new-page.html” with the new destination URL.

Step 2: The content attribute specifies the time delay (in seconds) before the redirect occurs. In this example, it’s set to 0, which means an immediate redirect.

Method 4: Using server-side scripting (e.g., PHP)

Step 1: Create a PHP file for the old URL (e.g., old-page.php).

Step 2: Add the following PHP code to the PHP file:


Replace “http://example.com/new-page.html” with the new destination URL.

Step 3: This PHP script sends an HTTP header to the browser, triggering a 301 redirect to the new URL.

Method 5: Using URL rewrite rules (Apache mod_rewrite or Nginx)

Step 1: For Apache, create or edit a .htaccess file in your website’s directory. For Nginx, edit your server block configuration.

Step 2: Add rewrite rules to redirect URLs. For example, for Apache with mod_rewrite:


Replace “old-page\.html$” with the old URL pattern and http://example.com/new-page.html with the new destination URL.

Step 3: Save the configuration file.

Step 4: These rules will redirect requests for the old URL to the new URL with a 301 status code.

Method 6: Using a content management system (CMS):

If your website is built on a CMS like WordPress, Joomla, or Drupal, there are usually plugins or settings within the CMS that allow you to set up URL redirects without directly editing server configuration files.

Here’s a step-by-step guide on how to redirect a URL to another URL in WordPress!

Method 7: Using a URL shortener 

URL shorteners are commonly used for this purpose, especially when you want to create a shorter and more user-friendly URL that redirects to a longer or less user-friendly one. 

Replug: Redirect long, complex URLs into short, user-friendly links

Replug is a popular URL shortening and link management platform that allows you to create short, branded, and trackable links.

Here’s how to redirect a URL to another URL using a URL shortener:

Step 1: Sign in to Replug or create an account for free. 

Step 2: In your Replug dashboard, click “Select your campaign” then paste your long URL into the “URL to shorten” field and click the “Create” button. 


Also read: How to mask a URL link using a URL shortener?

Step 3: Customize the short URL here to make it more user-friendly. You can add a custom slug to the link if desired. 


Note: You can also add some powerful features here to enhance your shortened URL and boost CTR. As shown in the image below:


Step 4: After configuring your link settings, save the link. Replug will generate a short, user-friendly link that you can use for redirection.

Also read: How to Create a Short URL: Step-by-Step Guide

Step 5: Replug provides analytics and tracking data for your short links. You can monitor click-through rates, geographic locations of users, and other insights to understand how your links are performing.

Replug simplifies the process of creating short, user-friendly links and managing URL redirection. It’s a valuable tool for individuals and businesses looking to make their links more accessible and trackable.

Shorten your links, amplify your brand.

Create shareable, trackable and fully customizable branded urls. Get more clicks with absolute link management features such as Bio Links, retargeting, deep Links, CTA’s and more.

Learn More!
fully customizable bio link


Why would I need to redirect a URL?

You might need to redirect a URL to update content, change domain names, enhance SEO, or create user-friendly, easy-to-share links.

What’s the difference between a permanent (301) and a temporary (302) redirect?

A 301 redirect is permanent and tells search engines that the old URL has been permanently moved. Whereas, a 302 redirect is temporary and indicates a temporary move.

Can I manually redirect a URL without any technical knowledge?

Yes, you can use user-friendly methods like CMS plugins or online URL shorteners to perform redirection without technical expertise.

Which method should I choose for URL redirection?

The method depends on your goals. Use HTTP redirects for permanent changes, JavaScript for client-side changes, and plugins for CMS-driven websites.

What are the SEO implications of URL redirection?

Properly implemented 301 redirects can preserve SEO rankings during URL changes, but it’s essential to maintain content quality and relevance.

You may also like:

How to Create Your Own URL Shortener?

How To Put A Link In TikTok Bio?

How to download Instagram videos?

Arslan Jadoon
Meet Arslan, a skilled website blog and content writer who combines creativity and expertise to deliver engaging and informative pieces that captivate audiences.

Amplify Your Marketing With Optimized Link Sharing

Over 35,000+ marketers, agencies, businesses, e-commerce stores and brands optimize and track their links using Replug and get better returns on their marketing efforts.

Share via
Copy link