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

hoangvu

New member
Joined
Jun 6, 2012
Messages
1,835
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

Well-known member
Joined
Jan 13, 2015
Messages
1,281
Points
113
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,835
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
3,289
Replies
1
Views
2,824
Replies
5
Views
3,654
Newer threads
Replies
5
Views
4,648
Replies
9
Views
3,803
Replies
3
Views
4,434
Replies
9
Views
4,810
Latest threads
Replies
0
Views
29
Replies
0
Views
31
Replies
1
Views
39
Replies
3
Views
96
Top