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

Marc0

Well-known member
Registered
Joined
Jun 6, 2012
Messages
890
Points
28
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

Member
Registered
Joined
Jan 24, 2015
Messages
34
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

Well-known member
Registered
Joined
Nov 11, 2014
Messages
433
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
Registered
Joined
Jan 13, 2015
Messages
866
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
 

Marc0

Well-known member
Registered
Joined
Jun 6, 2012
Messages
890
Points
28
Thanks guys for helps and I applied codes successfully

To be honest, too many works when I moved my site to a new host.
 
Latest Threads
Replies
0
Views
20
Replies
0
Views
41
Replies
1
Views
42
Replies
0
Views
237
Recommended Threads
Replies
3
Views
5,247
Replies
11
Views
4,229
Replies
1
Views
2,523

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

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