SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 28
  1. #1
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    what do you think is the best way to 301 redirect my entire domain?

    I developed a new site to display my demos. I could simply htaccess 301 my entire site. But then every visitor would be confused they didn't land on their expected page. But that's best for google. I could meta refresh after 5 seconds and say the site has moved, so good for visitors, but meta is bad for seo. I could php 301 it using the same ideas.

    Is there any other way I'm not thinking of? If you switched domain names, and you spent the last 6 years building seo for your old domain, how would you 301 redirect to your new domain? Remembering that I also want to inform visitors that I changed locations.

    Thanks, Eric W

  2. #2
    SitePoint Member
    Join Date
    Jan 2013
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whether your domain page has same category or not...In case,it would be same category users can easily identify their expected page, once you redirect the domain page to new page..

  3. #3
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    wow so I must be the first one to do this. I guess no body can offer their experience with this then.

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,057
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    I believe something like this in your htaccess would suffice.

    Code:
    <If "%{HTTP_HOST} != 'olddoamin.com'">
    	Redirect permanent / http://newdomain.com/
    </If>
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, Goolgle webmasters offers such information:
    https://support.google.com/webmaster...s&answer=83105

    It also explains how to avoid 404 erros. I am assuming that is what worries you.

  6. #6
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    I believe something like this in your htaccess would suffice.

    Code:
    <If "%{HTTP_HOST} != 'olddoamin.com'">
    	Redirect permanent / http://newdomain.com/
    </If>
    Thank you! What exactly does that code say and do? Thanks

  7. #7
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by winagain View Post
    Actually, Goolgle webmasters offers such information:
    https://support.google.com/webmaster...s&answer=83105

    It also explains how to avoid 404 erros. I am assuming that is what worries you.
    Good link. Thank you

  8. #8
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,057
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by EricWatson View Post
    Thank you! What exactly does that code say and do? Thanks
    Well first, oops, I may have mis-copied it (found it on Apache's website). It is supposed to check what domain is being accessed, and redirect to another.
    Code:
    <If "%{HTTP_HOST} != 'newdomain.com'">
    	Redirect permanent / http://newdomain.com/
    </If>
    So if the domain being access is not newdomain.com, perform a permanent redirect to newdomain.com
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  9. #9
    Floridiot joebert's Avatar
    Join Date
    Mar 2004
    Location
    Kenneth City, FL
    Posts
    823
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could 301 redirect visitors to the new domain, and on the new domain check the referrer for the old domain name and if the old domain name is found in the referrer, display a notice letting the visitor know what's going on.

  10. #10
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    A way other than @cpradio's is to use the following mod_rewrite:

    // With www
    Code:
    # Redirect old_domain.com to new_domain.com with 301
    RewriteCond %{HTTP_HOST} !^www\.new_domain\.com
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule .? http://www.new_domain.com%{REQUEST_URI} [R=301,L]
    // Without www
    Code:
    RewriteCond %{HTTP_HOST} !^new_domain\.com
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule .? http://new_domain.com%{REQUEST_URI} [R=301,L]
    This way for any page that existed on the old site as long as the same page names or index plus parameters will be redirected to the same page name on the new site. The seo bots will learn the 301 and your juice won't be lost.
    ictus==""

  11. #11
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    What about this redirect? Is it missing anything that the above examples have?


    Redirect 301 / http://newdomain.com/

  12. #12
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,057
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    If both domains point to the same location, you would likely introduce an infinite loop, as it is redirecting all requests to newdomain.com and if newdomain.com resolves to the same location as olddomain.com it will still enforce that redirection as it doesn't specify the request had to be made from a specific host.
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  13. #13
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    If both domains point to the same location, you would likely introduce an infinite loop, as it is redirecting all requests to newdomain.com and if newdomain.com resolves to the same location as olddomain.com it will still enforce that redirection as it doesn't specify the request had to be made from a specific host.
    I dont know. JdMorgan with 25,000 posts says to use that above one liner. http://www.webmasterworld.com/apache/3242480.htm. Sorry - not being argumentative - just trying to find the best way to do this.

  14. #14
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    OH WAIT! My bad. I miss spoke. I just realized. This is probably going to make it easy. They are not going to match from old to new - not 1:1. They are going to be olddomain.file.php and newdomain/folder/file.php. And the folder changes depending on the file group. So in that case what would be the best way? I have 800+ pages. So it's probably impracticable to redirect each seperatly. So should I just redirect the entire old domain to the new domain root?

  15. #15
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,057
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Can you give us more examples of the redirections you need? If there is a pattern, it wouldn't be terribly difficult to get the redirection to handle all 800 pages.

    For example:
    olddomain/file.php newdomain/folder/file.php (need to know how folder would be defined, hard coded?)
    olddomain/folder-file.php newdomain/folder/file.php (grab folder from filename)
    etc.

    Without know what you have and where you want it to go, then the only recommendation I have is to redirect all traffic to the root of the new domain (although it would be best to redirect to the new page location).
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  16. #16
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    Can you give us more examples of the redirections you need? If there is a pattern, it wouldn't be terribly difficult to get the redirection to handle all 800 pages.

    For example:
    olddomain/file.php newdomain/folder/file.php (need to know how folder would be defined, hard coded?)
    olddomain/folder-file.php newdomain/folder/file.php (grab folder from filename)
    etc.

    Without know what you have and where you want it to go, then the only recommendation I have is to redirect all traffic to the root of the new domain (although it would be best to redirect to the new page location).
    Good morning,

    I think it's going to be easiest to just redirect to the root but you tell me. I don't beleive there is going to be a pattern. I have 800+ css, php, htaccess, js, photoshop, etc demos and such. In the old domain they were all just in olddomain/code/demo.php. Now in the new domain I am going to group them into there corresponding folder. So css demos will go in newdomain/code/css/demo.php. PHP demos in newdomain/code/php/demo.php and so on. There will be about 17 newly named folders/groups that the files will be going into. Thanks!

  17. #17
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,057
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by EricWatson View Post
    Good morning,

    I think it's going to be easiest to just redirect to the root but you tell me. I don't beleive there is going to be a pattern. I have 800+ css, php, htaccess, js, photoshop, etc demos and such. In the old domain they were all just in olddomain/code/demo.php. Now in the new domain I am going to group them into there corresponding folder. So css demos will go in newdomain/code/css/demo.php. PHP demos in newdomain/code/php/demo.php and so on. There will be about 17 newly named folders/groups that the files will be going into. Thanks!
    Ah, you are probably right, it might not be easy to redirect all of those. I'd personally go the blanket redirection route at this point in time, if you weren't worried about losing your search results. If you want the search result to remain valid, you'll have to write conditions for each page unfortunately (or so it seems)...
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  18. #18
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Ok thanks. So what the best htaccess code for a blanket redirection to the new domain root?

  19. #19
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,057
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Are the two domains pointing to two different websites (possibly two separate servers)?

    If so, you can use your blanket one of
    Code:
    Redirect 301 / http://newdomain.com/
    If the two domains point to the same website folder (so you have the old file and the new files inter-mixed), then you need to use
    Code:
    <If "%{HTTP_HOST} != 'newdomain.com'">
    	Redirect permanent / http://newdomain.com/
    </If>
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  20. #20
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Hmmm. What am I then? It's on the same server. But a different folder I believe. Meaning I will delete the olddomain addson and add the new domain addon. So the host/server "should" view it as a new folder right?

    The host set up is... The main domain sits in public_html/ and the addon domain (the new and old domains) site at public_html/addondomain. Let me know if that's not clear. Thanks a lot for the continued help!

    Additionally they are not sub domains. But full fledge domains.

  21. #21
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,057
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by EricWatson View Post
    Hmmm. What am I then? It's on the same server. But a different folder I believe. Meaning I will delete the olddomain addson and add the new domain addon. So the host/server "should" view it as a new folder right?

    The host set up is... The main domain sits in public_html/ and the addon domain (the new and old domains) site at public_html/addondomain. Let me know if that's not clear. Thanks a lot for the continued help!

    Additionally they are not sub domains. But full fledge domains.
    If they are in separate folders, you can use the Redirect 301 / http://newdomain.com/ as well.

    The only time you would not want to use Redirect 301 / http://newdomain.com/ is if your old and new files are in the same folder. As that would create an infinite loop.
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  22. #22
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    Hi,The script that I earlier put, will redirect an old domain plus page name (including parameters) to the new domain. If the new site has some of the same page names then at least these pages would not loose their seo. For the others you could blanket redirect them to a sitemap in your 404:
    Code:
    ErrorDocument 404 /404.php
    RewriteEngine on
    ...
    ictus==""

  23. #23
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ServerStorm View Post
    Hi,The script that I earlier put, will redirect an old domain plus page name (including parameters) to the new domain. If the new site has some of the same page names then at least these pages would not loose their seo. For the others you could blanket redirect them to a sitemap in your 404:
    Code:
    ErrorDocument 404 /404.phpRewriteEngine on...
    That all sounds good to me. But unfortunately I dont really understand what you mean. Can you possibly rephrase that? The new domain has all of the same page names. It just has a folder in between it now where one was not there in the old domain. And the 404s? No getty?

  24. #24
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by EricWatson View Post
    That all sounds good to me. But unfortunately I dont really understand what you mean. Can you possibly rephrase that? The new domain has all of the same page names. It just has a folder in between it now where one was not there in the old domain. And the 404s? No getty?
    Hi Eric,

    I'll make it clear that although I've been pouring many hours recently into learning mod-rewrite specifics, I am not an expert, but what I'm talking about may very well work for you.

    So to be clear, the ErrorDocument 404 /404.php line is put in an .htaccess file inside the root of your new server. It goes prior to the RewriteEngine on like:
    Code:
    # This handler tells Apache to point any page request that come in to
    # redirect a page not found (404 error) to a custom 404.php page
    # It is a very good idea to put both a simple 404 message and a map of the
    # New site structure so people can navigate to the main site directly.
    
    ErrorDocument 404 /404.php
    RewriteEngine on
    
    # ... more rewrite code goes here
    So to do your rewriting from your old server to the new server's sub-directory you use a 301 - permanent redirect. Using 301s is the current recommended practise of redirecting domains. Search engine bots run through a 301 and will in time index as a permanent change. Meanwhile the SEO juice you've have will somewhat be retained. I mean somewhat as it seems that Google will honour most of your 301 redirects and your SERPs don't fall. Yahoo is not quite as good and Bing may not honour them at all. However they will help moreso than doing nothing.

    So on your new server in the root folder, create a .htaccess file, and put something like this:
    Code:
    RewriteEngine on
    RewriteRule ^([a-z\.]+)$ http://new_server.com/subfolder/$1 [R=301]
    With this if you click a link in a search that has <a href='http://old_server.com/puddles.html'>A number of pictures of puddles</a> then the user will be redirected to http://new_server/subfolder/puddles.html. As this is a generic match http://old_server.com/puddles.php or http://old_server.com/puddles.aspx will be redirected to http://new_server.com/subfolder/puddles.php and http://new_server.com/subfolder/puddles.aspx.

    With this all your web files will redirect to the new server and they will look for the same file names and extensions as on the old server.

    DK may be able to chime in here and give you a far superior way. I do know that the approach I recommend is not greedy or taxing on your old server.

    Regards,
    Steve
    ictus==""

  25. #25
    SitePoint Member
    Join Date
    Jan 2013
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's really nice topic of 301 redirection. It is a really awesome information about 301 Redirection and thanks to all about this discussion.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •