PradysTechBlog

Yet another blog

redirecting using .htaccess

If you were to change your website to a new domain or changed the location of an existing file, and you have your url indexed by search engines. If the pages are redirected you could end up loosing a lot of traffic by users getting the 404 error.

You can sort those by using redirection. This can be achieved by http-equiv, javascript or by using some server side code. But the simplest way is by using .htaccess 301 redirect.

This method is search engine friendly and is the easiest way around.

Just add the following code to your .htaccess file placed in your old site.

Redirect 301 /olddirectory/oldfile.html http://yoursite.com/newdirectory/newfile.html

redirect 301 (the instruction that the page has moved)

/old/old.htm (the original folder path and file name)

http://www.yoursite.com/newdirectory/newdirectory/newfile.html (new path and file name)

Test  immediately after implementing 301 redirects. If you find anything wrong, remove the redirect immediately.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: