Basic Redirect noob question. I have searched for some old threads regarding this but cant seem to find anything. I know you have to enter code for the redirect: For example where would I enter the below code? Into what file in my root directory? header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.newdomain.com/newpage.html"); exit(); ?> Please note that the domain i would like to redirect from has no site on it at the moment and is just a domain name with hosting.
hi, you can do this using that code in htaccess. RewriteRule ^oldpage.html?$ http://www.newdomain.com/newpage.html? [R=301]
The code you posted seems to be PHP. PHP is a script language for coding Web pages, so you should create a page with the name that you want to be redirected. For instance, you want this: page001.php --> page002.php The code shown should be in page001.php. Note that the name must end in .php and be sure to include "<?php" as the first line. Another option is to use a redirect line in .htaccess, like this: Redirect 301 page001.php /page002.php Here the names can be anything. Hope this helps.
Ok lets say.... I have a domain with nothing on it at all no file or anything. Would the best way for me to redirect that domain be by creating .htaccess file then inserting the correct code ?
OK. Therefore....the I should create .htaccess file and past the code into it ? IS that way its done ?
The .htaccess is usually already present as it is created by the system administrator. It contains nothing, its length is zero. Via FTP you can modify it, adding any of the redirect commands you were taught. Then test if the redirect works using your browser. If you have no files in the source domain, maybe the best option is: Redirect permanent / http://www.targetdomain.com