How to pass parameters through links without using question marks?

Discussion in 'PHP' started by gandalf117, Sep 21, 2010.

  1. #1
    Hello everyone,

    Here is a quite important and really hard to answer question.
    I know that google crawlers ignore long links, that is links with question marks in them and parameters after that. I have read a lot about how in order to get the pages on a website indexed only links with pure HTML URL should be used such as www .example.com/page.php

    When I want to dynamically build links with php that are intended to pass variables from one page to another there seems no other way but to use question marks and long links. Most of the time there are plenty of links pointing to the same page with only a single parameter in the url that determines a particular item to be displayed on the page. This is not only clumsy but also highly disliked by search engine crawlers.

    For example in a link such as <a href="www.example.com?par=1&par=2&par=3">link</a> how do you get rid of all the parameters after the question mark and still pass them to the page?
    What do you believe is the best practice to tackle this issue in php?
     
    gandalf117, Sep 21, 2010 IP
  2. mario212

    mario212 Peon

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Pass them with $_POST
     
    mario212, Sep 21, 2010 IP
  3. HungryMinds

    HungryMinds Active Member

    Messages:
    216
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    63
    #3
    Hi!

    Use hidden fields for passing values.

    Example:

    Page1.php

    <form action="Page2.php">
    <input type="hidden" name="par1" value="1" />
    <input type="hidden" name="par2" value="2" />
    <input type="hidden" name="par3" value="3" />
    <input type="submit" value="submit'>
    </form>

    Page2.php

    <?php
    print $_REQUEST["par1"] . "<br />";
    print $_REQUEST["par2"] . "<br />";
    print $_REQUEST["par3"];
    ?>
     
    HungryMinds, Sep 21, 2010 IP
  4. gandalf117

    gandalf117 Active Member

    Messages:
    111
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    yes, I was thinking about this, but the I want to pass the variable by clicking on a link. Is it practical and professional on a page with about fifty links to have 50 forms and what's worse 50 <input type="submit" value="submit'> buttons?
     
    gandalf117, Sep 21, 2010 IP
  5. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #5
    use htaccess
     
    gapz101, Sep 21, 2010 IP
  6. gandalf117

    gandalf117 Active Member

    Messages:
    111
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #6
    Would you elaborate on this a little bit? As far as I know htaccess is the directory-level configuration file. How can it help me to pass variables through links?
     
    gandalf117, Sep 21, 2010 IP
  7. Gray Fox

    Gray Fox Well-Known Member

    Messages:
    196
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    130
    #7
    It is most definitely not true that search engines "ignore" query strings (string after quotation mark in URL), but they may have problems with duplicate content if you have URLs like /?action=videos, /?action=videos&sort=views and /?action=videos&sort=views&page=3. If that's the case, the answer to your question is canonical
     
    Gray Fox, Sep 21, 2010 IP
  8. qualitypoint

    qualitypoint Peon

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Using mod_rewrite rules in htaccess file will solve your issue.

    You can refer this link if you need more details.
     
    qualitypoint, Sep 21, 2010 IP
  9. unknowncat

    unknowncat Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    mod rewrite, absolutely the way to go.
     
    unknowncat, Sep 21, 2010 IP
  10. lowridertj

    lowridertj Well-Known Member

    Messages:
    2,882
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    195
    #10
    lowridertj, Sep 21, 2010 IP
  11. Gray Fox

    Gray Fox Well-Known Member

    Messages:
    196
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    130
    #11
    To folks suggesting URL rewrites or form submission:
    - URL rewrites don't solve this problem if you need to get all those parameters passed via URL; that would only make those URLs more "search engine friendly", which is't all that helpful, contrary to popular belief. Besides, not all applications are suitable for URL rewriting.
    - JavaScript/hidden form submission hides parameters (since search engines mostly don't follow forms) and is almost like cloaking. That would also make same URLs display different content based on hidden POST parameters, which is also very bad.

    I strongly suggest that you read the blog article from my previous post. Don't trust that "search engines hate query strings" crap, there are too many "SEO experts" around here.
     
    Gray Fox, Sep 22, 2010 IP