Redirect (301 Permanently) without using .htaccess

Want to redirect your website to another place but can’t create .htaccess file?

Well this might be a solution to you, if your webhost supports server site php scripting.

The codes below will tell web-client (including search bot) that your website have been Moved Permanently to a new location and redirects them to a new location

The PHP version :
header ('HTTP/1.1 301 Moved Permanently');
header ('Location:');

The ASP version :
Response.Status="301 Moved Permanently"
Response.AddHeader "Location",\ ""

What’s wrong with META Refesh tag? Well, firstly, it isn’t supported by all web-client (including bots). Secondly, the search engine will ignore the META Refresh tag and stops indexing your webpage.

By sending server response code 301 Moved Permanently, will inform that your website have been moved to another location and search bots will note that and index the new location instead. :)

p/s: This tip is useful in an event you can’t create a .htaccess file in your webhost.

2 Replies to “Redirect (301 Permanently) without using .htaccess”

  1. I know, this thing occured to me… but still better than the lame META refresh…

    It’s handy on you index page when you dont have direct access to webserver setting and .htaccess

    Yes, the HTTP/1.0 is shorter.. :)

  2. this is good only if you have one page ..
    if the website has 1000 pages and you need to redirect them one by one .. still headache too..
    but if you can configure your ErrorDocument 404 .. then the problem is reduced lah..

    btw, i’ll use with HTTP/1.0 with such short response ..

Comments are closed.