• 03 - 92 126 905
  • To provide better experience,  we use cookies on our webpage. By clicking or navigating the site, you agree to allow our collection of information.

    How can we help you?

    Redirecting a website to another address

    Certainly everyone has already encountered a request to redirect a website temporarily, or permanently to another url, but you just didn’t know how to do it. Therefore, we will describe several ways for such redirection using various methods. However, as you will see, the result will always be the same.


    Redirect using .htaccess

    You will create a file named .htaccess in a webroot, type in the file:

    Redirect permanent / http://www.otherdomain.my/


    RewriteEngine On

    RewriteRule ^(.*)$ http://www.otherdomain.my/$1 [R=301,L,QSA]


    Redirect using link


    the easiest way

    it does not require server-side support

    a visitor to the website feels that he/she can decide for himself/herself where he/she wants to go

    Source code:

    <p> The page that you are looking for has been moved,

    <a href=”http://www.yourdomain.sk/contact.html”>

    contacts to XYZ can be found here </a></p>


    Although this is the easiest way to redirect, it is not the most appropriate for SEO optimisation, as search engines do not consider this method to be a redirect, as only partial assignment of off-page factors takes place.


    Meta tag redirection


    a very popular way of redirecting

    does not require server-side support

    The source code is inserted directly into the page header:

    <meta http-equiv=”refresh”



    Redirect using JavaScript


    the least certain way to redirect

    It is used when the redirecting address is not known in advance. For example, you can insert a script on a page to find out which page you have requested and redirect you to a similar page accordingly. However, JavaScript may not be supported on every server, nor is it suitable for search engines and robots, so I recommend a different way of redirecting.

    Example of redirecting using JavaScript:





    Redirect using PHP


    the easiest and most reliable way
    it uses the Header() function
    the source code is inserted at the top of the page:



    header(“HTTP/1.1 301 Moved Permanently”);

    header (“Location: http://www.yourdomain.sk/new-page.html”);

    header (“Connection: close”);



    Redirection in ASP

    Source code:

    <%@ Language=VBScript %>


    Response.Status = “301 Moved Permanently”

    ResponseAddHeader “Location”, “http://www.yourdomain.sk/”



    Redirection in ASP.NET

    Source code:

    <script runat=”server”>

    private void Page_Load(object sender, Syste.EventArgs e)


    Response.Status = “301 Moved Permanently”;