1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to use (?) in URL by .htaccess?

Discussion in 'General Programming Chat' started by nichkhun, Feb 7, 2013.

  1. nichkhun

    nichkhun Junior Member

    Joined:
    May 8, 2009
    Messages:
    102
    Likes Received:
    2
    Location:
    Palo Alto, CA
    Home Page:
    Have anyone know about way to write .htaccess that has included question mark sign in URL following:

    www.domain.com/review/product/title?ID=1

    I try to write following:

    RewriteRule ^.*/.*/.*?ID=(.*) /product.php?ID=$1&Keyword=$2

    But the results after access to product.php page is it called index.php page

    Thank you very much.
     
  2. cgimaster

    cgimaster Power Member

    Joined:
    Jun 30, 2012
    Messages:
    525
    Likes Received:
    311
    Gender:
    Male
    I don't see how that would work if you don't have the second variable.

    Here is how it should be based on your specifications:
    Code:
    RewriteRule ID=(.*)$ /product.php?ID=$1 [L]
    Given that you have a second variable and your URL is:
    Code:
    www.domain.com/review/product/title?ID=1&keyword=3
    Then you could do it like this:

    Code:
    RewriteRule ID=(.*)&keyword=(.*)$ /product.php?ID=$1&Keyword=$2 [L]