The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Friendly URL | GET parameters lost

  • This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
  • #44726

    Let’s say I have a website :

    And a webpage:

    I want to make it more friendly, so I use .htaccess:

    Which contains links to other “pages”. They are actually the same one, the only difference being the GET parameters from the URL, which would pull different content from the database.

    So by clicking the links within “page.php”, wether you’re on “” or “”, you’ll get to “”

    I want to make it more friendly too, so I use, again, .htaccess. The result would be “”, followed by all those values, separated by slashes: “”

    My question is: Within the page.php file, how on earth am I going to be able to make use of the GET parameters??

    $_GET[“category”] or $_GET[“page”] wouldn’t work, at least in my case. Does it work for you? It isn’t even logical to work. There is no “category” or “page” parameter in the URL. So when attempting to write $_GET[“category”], the server will analize the URL and it will need the actual parameter NAME as well as the VALUE. In our case, we only have the value. Someone, please fill me in?


    There are some parameters whose names I don’t want to show off in the URL. Anyway, I didn’t even know that that was possible! I should have thought of it…Thanks! Even though, I will not be able to use “isset” or “$_GET”, will I?


    So you’re saying that in the above example, while the browser will show the user:

    It will actually be able to detect wether a parameter is set or not? Like:

    Even though we do not have the real parameter name?

    The reason for this being that, in the “back”, the users are actually on:

    And regarding your personal choice: What do you mean, more exactly, by “redirect everything through index.php”?


    Here’s what I do – a very similar approach:


    # if the filename is a “real” file or directory, don’t rewrite.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    # if not, take the entire URL + query string and append it to index.php.
    RewriteRule ^.*$ index.php%{REQUEST_URI} [QSA,L]

    In php, you can get the original path the user typed with `$_SERVER` (or, on some hosts, `$_SERVER`), and the query string with `$_SERVER` (or, simply use the `$_GET` superglobal like normal).

    The difference between using `PATH_INFO` and `REQUEST_URI` (as @BenWalker suggests) is that the latter will return both the path info and the query string together (and there’s nothing wrong with that; I just find it less useful). `REQUEST_URI` will still be available to you regardless of how you rewrite the request.

    # example: user typed “ string”

    print $_SERVER;
    # prints “/pretty/url?ugly=query%20string”

    print $_SERVER;
    # prints “/pretty/url”

    print $_SERVER;
    # prints “ugly=query%20string”

    print $_GET;
    # prints “query string”


    I don’t understand. Why would you want to rewrite everything to “index.php”? Alright, as a programmer, I will still be able to get those parameters and their values. But as a user, whatever I would type, whether it’s or or I will be redirected to


    The request go trough index.php but the user won’t see that. It’s an easy way to make pretty urls. You only have one place in which you need to find out what the requested page was and then serve that page.


    > You only have one place in which you need to find out what the requested page was and then serve that page.

    So I will analize the requested page right in “index.php”, and I will redirect the user to that specific page?


    > This is because my URLs only include the module name in the path – everything else is in the query string.

    And, in your case, what do you use to get the query string? Simply GET or SERVER variables?


    explode() is what I was thinking about too.

    Sorry for asking if you use server variables..I know the whole point of your previous post was to clarify that. I just don’t know what I was thinking of.

    Anyway, thank you for your prompt and helping responses!
    I have definitely learned something from you.
    I’ll use your suggestions and maybe implement your techniques in future projects.

    Have a great day!

Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘Back End’ is closed to new topics and replies.