How do I redirect my site using a .htaccess file?

hoangvu

New member
Joined
Jun 6, 2012
Messages
1,873
Points
0
Does anyone guide me any tips on how do I redirect my site using a .htaccess file?
I'm getting problem with redirect from old url to new urls when moved a site to a new host.
 

boognish

New member
Joined
Jan 24, 2015
Messages
61
Points
0
Are you trying to redirect your old domain to a new domain or are you trying to redirect old urls to new urls all on the same domain?

Either way this brief tutorial might help: css-tricks(.)com/snippets/htaccess/301-redirects

Please let us know specifically what you are trying to accomplish and what you have tried within your .htaccess file that has failed you.
 
Last edited:

Hassan

New member
Joined
Nov 11, 2014
Messages
706
Points
0
Setup a 301 redirect for the entire domain
Code:
ewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.net/$1 [L,R=301,NC]
 

elcidofaguy

New member
Joined
Jan 13, 2015
Messages
1,282
Points
0
I'm getting problem with redirect from old url to new urls when moved a site to a new host.
Hi KellyLC,

On your last sentence I can't help feeling that perhaps you have moved hosts? If that is the case then you will need to set the DNS to point to the new webhost within your domain registrar settings account...

If its a domain redirect - then the easy way to do that is via your web host control panel via Domains|Redirects .... Just enter the new domain url for the redirect here...

In addition with redirects you should also consider whether its a permanent (301) or temporary redirect (302)... The permanent redirect 301 will transfer link juice and temporary will not...

For domain level redirect add this to your .htaccess file (noting the code 301 or 302 for permanent or temporary):

Code:
Redirect 301 / http://my-new-website.com/
For page redirects use this:
Code:
Redirect /index.html http://my-new-website.com/newdirectory/
I hope that helps!

Best of Luck,

Sid
 

hoangvu

New member
Joined
Jun 6, 2012
Messages
1,873
Points
0
Thanks guys for helps and I applied codes successfully

To be honest, too many works when I moved my site to a new host.
 
Older threads
Replies
4
Views
2,637
Replies
1
Views
2,234
Replies
5
Views
2,809
Newer threads
Replies
5
Views
2,990
Replies
9
Views
3,015
Replies
3
Views
3,272
Replies
9
Views
3,934
Latest threads
Replies
2
Views
28
Replies
3
Views
22
Replies
1
Views
41
Replies
2
Views
30
Replies
6
Views
45

Latest postsNew threads

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top