To redirect a webpage to another using HTML, you can use meta tag with http-equiv=”refresh”.
Visit https://NEW-URL-HERE/
To redirect a webpage to another using HTML, you can use meta tag with http-equiv=”refresh”.
Visit https://NEW-URL-HERE/
To redirect a domain to HTTPS, Click on the website in IIS, you will see
If you don’t see the “URL Rewrite” button, you need to install “URL Rewrite” extension
https://www.iis.net/downloads/microsoft/url-rewrite
Click on “URL Rewrite” button. On the next screen click on “Add Rule(s)” link on the right side menu.
Select “Blank Rule”, then click OK button.
On the next screen, enter the following details
Name = SSL Pattern = (.*)
Keep all other options default.
Scroll down, expand “conditions” on the same screen. Click on Add button
Enter the following values, keep everything else default as shown in the above picture.
Condition input = {HTTPS} Pattern = ^OFF$
Click “OK” button.
Scroll Down to the actions section
Action type = Redirect Rewrite URL = https://{HTTP_HOST}{REQUEST_URI} Redirect type = Permanent (301)
Click “Apply” from the right side “Actions” menu to save the changes.
Create a file with the name “web.config” in the document root of your website with the following content.
You need “URL Rewrite” IIS module installed for this to work.
A WordPress website needs to migrate to a different domain, on a new domain site use static HTML pages. On the source site, WordPress is configured to use URL like https://domain1/page-name/, on the new server, the same page available on URL https://domain2/page-name.html
Source = https://domain1/page-name/ Destinatation = https://domain2/page-name.html
To do the redirection, edit Nginx configuration for the website, on top of it (inside server entry), add
rewrite ^/$ https://new-domain.tld permanent; rewrite ^(.*)/$ https://new-domain.tld$1.html permanent; rewrite ^(.*)$ https://new-domain.tld$1.html permanent;
Restart Nginx
systemctl restart nginx
See Nginx Redirect
To redirect a site to URL with www using PHP, you can use the following PHP code
<?php
$domainName = $_SERVER['HTTP_HOST'];
if (strpos($domainName, 'www') === false) {
header("HTTP/1.1 301 Moved Permanently");
$urlNew = 'https://www.' . $domainName . $_SERVER['REQUEST_URI'];
Header("Location: $newUrl");
exit;
}
Add this code in your index.php file or another file included by index.php
See Redirect
When you host a web site, many web hosting providers allow your web site access using multiple urls like yourdomain.com, www.yourdomain.com. If you have a dedicated IP address, your web site become available on the IP address also. It is bad for SEO to have a site available in multiple URLs. If search engine index your web site contents using differnt URLs, that will affect your page ranking.
To ge beter search ranking, you need to deicde which URL you want search engines to index. This can be with www or with out www, it is more of a personal choice. In my case, i decided to use with out www (https://serverok.in) to make URL shorter. Once you decided the URL you need google to index, you need to redirect all other URLs used to access your web site to this URL. This is called Canonical url.
On Apache web server, you can do this using .htacess file. Create an .htaccess file with following content
RewriteEngine on RewriteCond %{SERVER_NAME} !=www.yourdomain.com RewriteRule ^ https://www.yourdomain.com%{REQUEST_URI} [END,NE,R=permanent]
In above code, replace www.yourdomain.com with the Canonical URL of your web site. If you don’t use www, then remove the www from the redirect code. What the code doing is check if visitor is using proper Canonical URL to access your web site, if not redirect it to Canonical url. In third line, we redirect to https, if you don’t have SSL installed, change it to “http” instead of “https”.
See redirect
To redirect a folder to another using .htaccess, create
RedirectMatch 301 ^/OLD_FOLDER/(.*)$ /NEW_FOLDER/$1
Or
RewriteEngine On RewriteRule ^OLD_FOLDER/(.*)$ /NEW_FOLDER/$1 [R=301,NC,L]
Or
Redirect 301 /OLD_FOLDER /NEW_FOLDER
if new folder is on another domain, you can use https://new-domain.com/OLD_FOLDER
See Redirect
Redirect a site to HTTPS using .htaccess file
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
Redirect a web site to SSL using Apache Virtual Host
ServerName www.yourdomain.com
Redirect permanent / https://www.yourdomain.com/
OR
RewriteEngine on
RewriteCond %{SERVER_NAME} =yourdomain.com [OR]
RewriteCond %{SERVER_NAME} =www.yourdomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
Redirect a Site to HTTPS using PHP
if ($_SERVER["HTTPS"] != "on") {
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://www.yourdomain.com");
}
Redirect www to non-www URL
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ https://yourdomain.com/$1 [L,R=301]