{IFC}{IndonesiaForumCyber}


    301 Redirect Examples

    Share
    avatar
    pcpkomputer
    Administrator
    Administrator

    Jumlah posting Jumlah posting : 11
    Reputasi Reputasi : 0
    Join date Join date : 13.01.12
    Age Age : 19
    Lokasi Lokasi : Pacitan

    301 Redirect Examples

    Post  pcpkomputer on Mon Jan 23, 2012 6:51 am


    Ok now i will share about a Redirect Pages :)
    Ok lets begin :)
    To Move a single page
    Quick, easy and seamless for your visitors.
    ?
    1
    Redirect 301 /oldpage.html [You must be registered and logged in to see this link.]
    To Move an entire site
    This will catch any traffic on your old site and redirect it to your index page on your new server. If you want to redirect each page to its new spot, this isn’t the one for you.
    ?
    1
    Redirect 301 / [You must be registered and logged in to see this link.]
    Changed file extension?

    This example is perfect if you’ve decided to switch to .php from .html pages. It will look for any .html page and redirect it to .php (ie [You must be registered and logged in to see this link.] and redirect it to [You must be registered and logged in to see this link.] Now, be careful with this, it does mean any html page. I did this on one of my sites and had totally forgotten I had an iframe with .html content on some pages… I didn’t notice for weeks that it was broken :S.
    So learn from my mistake check, double check, then check again.
    ?
    1
    RedirectMatch 301 (.*)\.html$ [You must be registered and logged in to see this link.]
    Redirect www to non www version of site
    It’s best to stick with either always using [You must be registered and logged in to see this link.] or just example.com. Allowing both can confuse the search engines. So here’s how to force your site to always show the non-www version. (Search for “canonical url errors” in your favorite search engine for more info.)
    Note: If you do use either of the next 2 codes below, and use a secure server (ie. https:) be sure to check that it doesn’t redirect the secure to the insecure version. I’m pretty sure this will do that and that isn’t something you want!
    ?
    1
    2
    3
    4
    5
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^example\.com
    RewriteRule (.*) [You must be registered and logged in to see this link.] [R=301,L]
    Redirect non-www to www
    Same as above except in the reverse, this one forces the [You must be registered and logged in to see this link.] into your url.
    ?
    1
    2
    3
    4
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^example.com [NC]
    RewriteRule ^(.*)$ [You must be registered and logged in to see this link.] [L,R=301]
    Redirect example.com/index.php to example.com/
    Another snippet that I’ve heard is a good idea to make sure search engines don’t give you a duplicate content penalty, this will also redirect example.com/folder/index.php to example.com/folder/.
    ?
    1
    2
    3
    4
    5
    Options +FollowSymLinks
    RewriteEngine on
    # index.php to /
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
    RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
    I might add more later as I need them, for now those are the one’s I use on a few different sites I run. Remember, I can’t stress enough to test, test and re-test anything you do to your .htaccess file.
    Method 2 – PHP Redirect
    This works well if your pages are php enabled, simply place this code at the very top of the old file and your visitors will be smoothly sent to the new location.
    ?
    1
    2
    3
    4
    <?php
    Header("HTTP/1.1 301 Moved Permanently");
    Header("Location: [You must be registered and logged in to see this link.]
    ?>
    Method 3 – Meta Redirect
    I’d really advise against redirecting this way since many search engine have difficulties with this one (and spammers have been known to use this in very bad ways) so it might get your page in a heap of trouble! Some browsers also don’t read it properly so your would-be visitors may get stranded. Seriously, it really isn’t advisable to use this anymore but if you don’t have access to php or an .htaccess file on your host it might be the best (or only) way so here it is.
    ?
    1
    <meta http-equiv="refresh" content="10; url=http://example.com/">
    Content=”10; tells the browser to wait 10 seconds before transfer, choose however long you would like, you can even choose 0 to give a smoother transition.
    enjoy …


    Page loaded in: 0.97 seconds

    Hacker Indonesia ©️ 2012 [C]yber [P]cpkomputer
    Pcpkomputer Template re-design by Padang Perwira Yudha





    :D :) :( :o :shock: 8) :lol: :x :P :oops: 😢 :evil: :twisted: :roll: ;) :!: :?: :idea: :arrow: :| :face: ⭐ :suspect: ❤ 🇳🇴 :@: :cyclops: 🤡 :pirat: 👅 :silent: :pale: 👽 🐱 🐒 🐷 🐰 :bounce: 😕 :affraid: :bball:

      Waktu sekarang Sun May 27, 2018 4:41 am