Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Search Engine Optimization (SEO) (http://www.go4expert.com/forums/seo-forum/)
-   -   301 permanent redirect in PHP (http://www.go4expert.com/forums/301-permanent-redirect-php-t605/)

coderzone 24Feb2006 19:58

301 permanent redirect in PHP
 
Whenever we change the names of any files on webserver its better to make a 301 permanent redirect from the old URL to the new URL and for Linux server you can use the .htaccess to make the permanent redirect. I find a disadvantage of this as it is very much dependent on the OS of the server and if you are changing hosts then there could be a problem of old URL not being redirected and so its better to put the redirection into the code. Here are the code snippets to achive the same.
PHP
Code: PHP

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


aspguy 24Feb2006 20:02

Re: 301 permanent redirect in ASP and ASP.NET
 
In ASP.NET
Code: ASP

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
  Response.Status = "301 Moved Permanently";
  Response.AddHeader("Location","http://www.newdomain.com/");
}
</script>

and in ASP
Code: ASP

Response.Clear
Response.Status = 301
Response.AddHeader "Location", "newUserLogin.asp"
Response.Flush
Response.End


jspguy 24Feb2006 20:08

Re: 301 permanent redirect in JSP
 
Code:

response.sendError(response.SC_MOVED_PERMANENTLY, "/newURL.jsp");

shabbir 24Feb2006 20:13

Re: 301 permanent redirect in PHP
 
Edited title of asp redirect and jsp redirect post.


All times are GMT +5.5. The time now is 23:30.