need simple htaccess code

Discussion in 'Programming' started by tyankee, Dec 6, 2012.

  1. #1
    i moved from an old script to a new script and many of the old pages are backlinked and indexed in google.. the old script is GONE so i need to redirect anything that comes into the website from these old links to the home page.

    an example of an old page - www.website.com/show.php?show=single&id=2156. there may be hundreds of these that all start with www.website.com/show.php?

    how do i redirect them all to the home page without having to list every one of them in my htaccess file.
     
    tyankee, Dec 6, 2012 IP
  2. desingshop98

    desingshop98 Greenhorn

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #2
    I too need this , can anyone please help with this ?
     
    desingshop98, Dec 7, 2012 IP
  3. tyankee

    tyankee Well-Known Member

    Messages:
    1,023
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    150
    #3
    anyone??? the info found on the net is all too confusing..
     
    tyankee, Dec 7, 2012 IP
  4. yachi_5

    yachi_5 Well-Known Member

    Messages:
    249
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    120
    #4
    You can use http://htaccessredirect.net/index.php

    This site will create the code that you can paste in .htaccess file

    Let me know if this help. Otherwise i will provide you the exact code.
     
    yachi_5, Dec 10, 2012 IP
  5. tyankee

    tyankee Well-Known Member

    Messages:
    1,023
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    150
    #5
    nice site but it doesn't help me with 'wildcarding' files.. for example there are hundreds of files that start with '/show.php?' and i'd like to redirect them all to one page..
     
    tyankee, Dec 10, 2012 IP
  6. Annabelle1

    Annabelle1 Active Member

    Messages:
    185
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    #6
    I have the same problem above, can anyone help us?

    Thanks
     
    Annabelle1, Dec 10, 2012 IP
  7. pr0t0n

    pr0t0n Well-Known Member

    Messages:
    243
    Likes Received:
    10
    Best Answers:
    10
    Trophy Points:
    128
    #7
    To redirect all such links to your home page you can add this to your .htaccess file:
    
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{QUERY_STRING} ^
    RewriteRule ^show\.php$ /? [L,R=301]
    redirect 301 /show.php http://www.website.com/
    
    Code (markup):
    Lines 1-2 you don't need if you already have those in your .htaccess file, so make sure to check that first.
    Lines 3-4 take all queries on your show.php script and 301 redirect all to / (your site index) and cut off queries.
    Line 5 redirects all direct hits to show.php without queries to your index page.

    Cheers.
     
    pr0t0n, Dec 11, 2012 IP