Redirecting a website to another location is an easy process that can be done with the quick use of the Internet browser. At times, the website that you are looking at might be under construction and you might need to redirect it to another website.

This is where the scrolling option on the top bar comes into play. This article will help you understand how to redirect a website to another location so you can get back to your search.

 

Here I will show few ways to Redirect A Page Website. hope the information might be helping with your work. So let’s check the method

Redirect using HTML Code

Meta tag http-equiv refresh is used to tell the browser to refresh or reload the page and is usually placed in the section of an HTML document.

<meta http-equiv="refresh" content="5"/>

The option content defines the time in seconds of how long should the browser wait to reload the page.

To redirect to another site, the option content need to slightly be changed to include the URL it is to be redirected to and as in the following example, will immediately redirect to http://www.thedevline.com

<meta http-equiv="refresh" content="0;url=http://www.thedevline.com"/>

Redirect using JavaScript Code

JavaScript redirection is another process if you are familiar with JavaScript.First, decide Control over what page is loaded into the browser rests in the JavaScript property window.location.

By setting window.location equal to a new URL, you will turn, change the current web page to the one that is specified.

If you wanted to redirect all your visitors to www.yourdnewomain.com when they arrived at your site.

Then you can use JavaScript, you can set the location.href of the window:

<script type="text/javascript">
    window.location.href = "http://www.yourdomain.com/somepage.html";
</script>

Redirect using .htaccess

.htaccess is very powerful.Since .htaccess is a hidden system file. Even any syntax error page easily redirects to another place.

Here I will show some option for the redirection page. just take a look

Instructions

Step 1: Create an empty text file using a text editor such as notepad, and save it as htaccess.txt.

Copy & the past the code insert the file.

RewriteEngine on
# remove trailing slash
RewriteRule (.+)/$ /~account/$1 [L,R=301]

# add trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ /~account/$1/ [L,R=301]

# perform redirect if thedevline.com
RewriteCond %{HTTP_HOST} ^www.thedevline.com$ [NC]
RewriteRule ^(.*)$ http://www.google.com/~account/$1 [R=301,L]

Replace the 3 occurrences of ~account with the name of the actual account.

Step 2: Now Upload them htaccess.txt via FTP client application on your server. Once uploaded to the server you can rename the file to .htaccess. just it.

Redirect www to non www version of site

Options +FollowSymLinks 
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example.com
RewriteRule (.*) http://example.com/$1 [R=301,L]

Redirect non-www to www

Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^example.com [NC] 
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

Redirect example.com/index.php to example.com

Options +FollowSymLinks
RewriteEngine on
# index.php to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /.*index.php HTTP/
RewriteRule ^(.*)index.php$ /$1 [R=301,L]

Note: The definitive guide on Apache directives that can be used in .htaccess files can be found here:http://httpd.apache.org/docs/current/mod/core.html


Redirect using PHP Code

if your pages are PHP enabled, simply place this code at the very top of the old file and your visitors will be smoothly sent to the new location.

<?php 
Header("HTTP/1.1 301 Moved Permanently");
Header("Location: http://www.example.com/");
?>

Redirect using PHP Code For Mobile Version

If you have 2 versions of your website 1 for web version 2 for only for mobile enable.then here a solution using the same domain you can send your visitor for different platform.

like the user using a smartphone to visit your site example.com than user going to your mobile enable site where you can send your user.

Beside when web user types example.com than user going to your web version of your website.


Step 1: Create an empty .php file using a text editor such as notepad, and save it as index.php.Copy & the past the code insert the file. place the index.php in your root folder.


<?php
function detect_mobile_device(){

// check if the user agent value claims to be windows but not windows mobile
if(stristr($_SERVER['HTTP_USER_AGENT'],'windows')&&!stristr($_SERVER['HTTP_USER_AGENT'],'windows ce')){
return false;
}
// check if the user agent gives away any tell tale signs it's a mobile browser
if(eregi('up.browser|up.link|windows ce|iemobile|mini|mmp|symbian|midp|wap|phone|pocket|mobile|pda|psp',$_SERVER['HTTP_USER_AGENT'])){
return true;
}
// check the http accept header to see if wap.wml or wap.xhtml support is claimed
if(stristr($_SERVER['HTTP_ACCEPT'],'text/vnd.wap.wml')||stristr($_SERVER['HTTP_ACCEPT'],'application/vnd.wap.xhtml+xml')){
return true;
}
// check if there are any tell tales signs it's a mobile device from the _server headers
if(isset($_SERVER['HTTP_X_WAP_PROFILE'])||isset($_SERVER['HTTP_PROFILE'])||isset($_SERVER['X-OperaMini-Features'])||isset($_SERVER['UA-pixels'])){
return true;
}
// build an array with the first four characters from the most common mobile user agents
$a = array(
'acs-'=>'acs-',
'alav'=>'alav',
'alca'=>'alca',
'amoi'=>'amoi',
'audi'=>'audi',
'aste'=>'aste',
'avan'=>'avan',
'benq'=>'benq',
'bird'=>'bird',
'blac'=>'blac',
'blaz'=>'blaz',
'brew'=>'brew',
'cell'=>'cell',
'cldc'=>'cldc',
'cmd-'=>'cmd-',
'dang'=>'dang',
'doco'=>'doco',
'eric'=>'eric',
'hipt'=>'hipt',
'inno'=>'inno',
'ipaq'=>'ipaq',
'java'=>'java',
'jigs'=>'jigs',
'kddi'=>'kddi',
'keji'=>'keji',
'leno'=>'leno',
'lg-c'=>'lg-c',
'lg-d'=>'lg-d',
'lg-g'=>'lg-g',
'lge-'=>'lge-',
'maui'=>'maui',
'maxo'=>'maxo',
'midp'=>'midp',
'mits'=>'mits',
'mmef'=>'mmef',
'mobi'=>'mobi',
'mot-'=>'mot-',
'moto'=>'moto',
'mwbp'=>'mwbp',
'nec-'=>'nec-',
'newt'=>'newt',
'noki'=>'noki',
'opwv'=>'opwv',
'palm'=>'palm',
'pana'=>'pana',
'pant'=>'pant',
'pdxg'=>'pdxg',
'phil'=>'phil',
'play'=>'play',
'pluc'=>'pluc',
'port'=>'port',
'prox'=>'prox',
'qtek'=>'qtek',
'qwap'=>'qwap',
'sage'=>'sage',
'sams'=>'sams',
'sany'=>'sany',
'sch-'=>'sch-',
'sec-'=>'sec-',
'send'=>'send',
'seri'=>'seri',
'sgh-'=>'sgh-',
'shar'=>'shar',
'sie-'=>'sie-',
'siem'=>'siem',
'smal'=>'smal',
'smar'=>'smar',
'sony'=>'sony',
'sph-'=>'sph-',
'symb'=>'symb',
't-mo'=>'t-mo',
'teli'=>'teli',
'tim-'=>'tim-',
'tosh'=>'tosh',
'treo'=>'treo',
'tsm-'=>'tsm-',
'upg1'=>'upg1',
'upsi'=>'upsi',
'vk-v'=>'vk-v',
'voda'=>'voda',
'wap-'=>'wap-',
'wapa'=>'wapa',
'wapi'=>'wapi',
'wapp'=>'wapp',
'wapr'=>'wapr',
'webc'=>'webc',
'winw'=>'winw',
'winw'=>'winw',
'xda-'=>'xda-'
);
// check if the first four characters of the current user agent are set as a key in the array
if(isset($a[substr($_SERVER['HTTP_USER_AGENT'],0,4)])){
return true;
}
}

function detect_iphone(){
return true;
}
// example 1 - detect and redirect mobile browsers
if(detect_mobile_device()){
header('Location: http://mobile.thedevline.com');
exit;
}

// example 2 - detect and redirect desktop browsers
if(!detect_mobile_device()){
header('Location: http://www.thedevline.com/');
exit;
}

// example 3 - send iphone to specific site
if(detect_iphone()){
header('Location: http://iphone.thedevline.com/');
exit;
}
?>

Conclusion

We hope you enjoyed our article on how to move a website from one location to another. We know it can be a task to replace a website’s hosting and moving the website to another location.

This is a great place to start for any website owners who are looking for a company to help them out. If you haven’t started looking for companies to take over your website hosting, now might be a good time to do so.

It’s always difficult to find help for this type of work when you need it, so please rest assured that we are here for you. Please don’t hesitate to reach out to us at. Thank you for reading, we would love to hear from you!

Affiliate Disclaimer : As an Amazon Associate I earn from qualifying purchases.