How to redirect few urls http to https?

by cortez.connelly , in category: Third Party Scripts , a month ago

How to redirect few urls http to https?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by orpha , a month ago

@cortez.connelly 

To redirect a few specific URLs from HTTP to HTTPS, you can use the following method:


Using .htaccess file:

  1. Access your website's root directory using an FTP client or file manager.
  2. Make sure to create a backup of your .htaccess file before making any changes.
  3. Open or create the .htaccess file in a text editor.
  4. Add the following code to redirect the specific URLs from HTTP to HTTPS:
1
2
3
4
5
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/url1 [OR]
RewriteCond %{REQUEST_URI} ^/url2
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


Replace 'url1' and 'url2' with the actual URLs that you want to redirect from HTTP to HTTPS. 5. Save the .htaccess file and upload it back to your server.


This code will check if the requested URL matches either 'url1' or 'url2' and if it is accessed over HTTP. If both conditions are met, it will redirect the user to the HTTPS version of the same URL.


Please note that this method requires access to the server's .htaccess file and the ability to modify it. If you are not comfortable making these changes, you may want to consult with a web developer or your hosting provider for assistance.