How to Redirect all the annoying /?p=NUMBER requests

Discussion in 'Apache' started by misohoni, Jun 11, 2014.

  1. #1
    I bought a site but all the error logs are showing invalid requests to pages that don't exist:
    /?p=32
    /?p=250
    - Can I redirect them in one go using .htaccess to the / page?
     
    misohoni, Jun 11, 2014 IP
  2. ironcladservers

    ironcladservers Well-Known Member

    Messages:
    389
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    115
    #2
    This should work:
    <IfModule mod_rewrite.c>
    RewriteCond %{QUERY_STRING} ^p=1$
    RewriteRule (.*) http://url-to-redirect-to/ [R=301,L]
    </IfModule>
    Code (markup):
     
    ironcladservers, Jun 11, 2014 IP
  3. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #3
    Thanks but it didn't work. Is it setup for ?p= ?
    Also I see a 1 infront of the $ ?
     
    misohoni, Jun 11, 2014 IP
  4. ironcladservers

    ironcladservers Well-Known Member

    Messages:
    389
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    115
    #4
    Sorry should have tested it first... Try this instead, should work:
    RewriteCond %{QUERY_STRING} /?p=(\d*)
    RewriteRule ^$ ? [R=301,L]
    Code (markup):
     
    ironcladservers, Jun 11, 2014 IP
  5. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #5
    Thanks that's better but it doesn't redirect to url-to-redirect-to like it did before? Could you fix it? thanks man
     
    misohoni, Jun 11, 2014 IP
  6. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #6
    Hi could someone update this so that it redirects to a url? thanks
     
    misohoni, Jun 13, 2014 IP