static URLs

Discussion in 'HTML' started by Jonathan N. Little, Apr 2, 2006.

  1. Okay I have been futzing with this for a bit, so a request other viewpoints.

    Using a website database and you want to present with static URLs so a
    call to:

    http://www.example.com/frontend.php?id=2

    Becomes:

    http://www.example.com/page/2

    With .htaccess:
    RewriteRule ^page/([\d]*) frontend?id=$1 [L]

    Ok, that takes care of static link in a webpage, but what if you want to
    get a page as a result of some form query and still want the result to
    appear as a static URL? Say a page selector form a could go to a
    intermediate parsing script like:

    <form action="http://www.example.com/q2url.php">
    <select name="id">
    <option value="25">Some page</option>
    ....

    Where q2url.php is:

    $id = $_GET['pageID'];
    $redirect = "http://www.example.com/page/$id";
    header("Location: $redirect");

    So the result will appear again as a static:
    http://www.example.com/page/25

    Or is there another way to do this with a rewrite rule. If so any
    advantages/disadvantages?



    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Apr 2, 2006
    #1
    1. Advertising

  2. Jonathan N. Little wrote:

    > Okay I have been futzing with this for a bit, so a request other
    > viewpoints.
    >
    > Using a website database and you want to present with static URLs so a
    > call to:
    >
    > http://www.example.com/frontend.php?id=2
    >
    > Becomes:
    >
    > http://www.example.com/page/2
    >
    > With .htaccess:
    > RewriteRule ^page/([\d]*) frontend?id=$1 [L]
    >
    > Ok, that takes care of static link in a webpage, but what if you want to
    > get a page as a result of some form query and still want the result to
    > appear as a static URL? Say a page selector form a could go to a
    > intermediate parsing script like:
    >
    > <form action="http://www.example.com/q2url.php">
    > <select name="id">
    > <option value="25">Some page</option>
    > ...
    >
    > Where q2url.php is:
    >
    > $id = $_GET['pageID'];
    > $redirect = "http://www.example.com/page/$id";
    > header("Location: $redirect");
    >
    > So the result will appear again as a static:
    > http://www.example.com/page/25
    >
    > Or is there another way to do this with a rewrite rule. If so any
    > advantages/disadvantages?


    I can't think of a better way. The initial URL is created by the user-agent,
    and this will always create ?id=NNN URLs. You may intercept the form
    submission using JavaScript, construct the correct URL and use
    window.location. But your q2url.php should still be in place to handle
    non-JS user-agents.

    BTW: make sure, your 'page selector' is not the only way to open a page, or
    search engines will not find it.


    --
    Benjamin Niemann
    Email: pink at odahoda dot de
    WWW: http://pink.odahoda.de/
    Benjamin Niemann, Apr 2, 2006
    #2
    1. Advertising

  3. Benjamin Niemann wrote:
    > Jonathan N. Little wrote:
    >
    >> Okay I have been futzing with this for a bit, so a request other
    >> viewpoints.
    >>
    >> Using a website database and you want to present with static URLs so a
    >> call to:
    >>
    >> http://www.example.com/frontend.php?id=2
    >>
    >> Becomes:
    >>
    >> http://www.example.com/page/2
    >>
    >> With .htaccess:
    >> RewriteRule ^page/([\d]*) frontend?id=$1 [L]
    >>
    >> Ok, that takes care of static link in a webpage, but what if you want to
    >> get a page as a result of some form query and still want the result to
    >> appear as a static URL? Say a page selector form a could go to a
    >> intermediate parsing script like:
    >>
    >> <form action="http://www.example.com/q2url.php">
    >> <select name="id">
    >> <option value="25">Some page</option>
    >> ...
    >>
    >> Where q2url.php is:
    >>
    >> $id = $_GET['pageID'];
    >> $redirect = "http://www.example.com/page/$id";
    >> header("Location: $redirect");
    >>
    >> So the result will appear again as a static:
    >> http://www.example.com/page/25
    >>
    >> Or is there another way to do this with a rewrite rule. If so any
    >> advantages/disadvantages?

    >
    > I can't think of a better way. The initial URL is created by the user-agent,
    > and this will always create ?id=NNN URLs. You may intercept the form
    > submission using JavaScript, construct the correct URL and use
    > window.location. But your q2url.php should still be in place to handle
    > non-JS user-agents.
    >
    > BTW: make sure, your 'page selector' is not the only way to open a page, or
    > search engines will not find it.


    Yes very true, no this 'page selector ' is in *addition* to the standard
    navigation. Just wanted both methods to product the same static URL result.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Apr 2, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kaidi
    Replies:
    5
    Views:
    454
    Andrew Thompson
    Jan 4, 2004
  2. ITistic
    Replies:
    2
    Views:
    476
    bruce barker
    Jun 12, 2007
  3. Nathan Sokalski

    Converting Relative URLs into Absolute URLs

    Nathan Sokalski, Aug 11, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    731
    Sriram Srivatsan
    Aug 12, 2008
  4. Adam Monsen

    JDBC URLs ...not really URLs?

    Adam Monsen, Feb 6, 2009, in forum: Java
    Replies:
    11
    Views:
    6,122
    Adam Monsen
    Feb 8, 2009
  5. Steve T.

    dynamic URLS convert to static URLS for search engines

    Steve T., Mar 1, 2004, in forum: ASP .Net Web Services
    Replies:
    7
    Views:
    274
    Steve T.
    Mar 4, 2004
Loading...

Share This Page