How to redirect url via .htaccess?

Member

by daisha , in category: Third Party Scripts , 3 months ago

How to redirect url via .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by adan , 3 months ago

@daisha 

To redirect a URL using .htaccess, you can use the following code:

  1. Open your .htaccess file in a text editor or FTP client.
  2. Add the following code to redirect a specific URL to a new URL:
1
Redirect 301 /old-url/ http://www.example.com/new-url/


This code will redirect any requests for the old URL to the new URL with a permanent (301) redirect.

  1. Save the .htaccess file and upload it to the root directory of your website using an FTP client or file manager.
  2. Test the redirect by entering the old URL in a web browser and verifying that it redirects to the new URL.


Note: Make sure to replace "/old-url/" and "http://www.example.com/new-url/" with your actual URLs.