I am presently using Apache 2.2

I'm able to do simple such things as

RewriteRule ^/news$ /page/news.php [L]
RewriteRule ^/news/(.*)$ /page/news.php?id=$1 [L]

but let's say I wish to send 2 parameters such as this


Lastly, I wish to also know applying Search engine optimization friendly URL like stackoverflow

though I'm able to obtain access to a webpage with URL like


Just designing that URL with


Produce some suggestion with example clips.

I understand the PHP symfony framework enables you to achieve that.

How do you use it : In apache config, use mod_rewrite to redirect ALL incoming resquest to some single access point (in symfony this really is known as the "front controller")

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteRule ^(.*)$ index.php [QSA,L]

Within this front controller you will produce a "Request" object which holds all of the informations supplied by the URL.

For instance you can state that the very first factor following the "/" may be the title from the PHP file to call and anything else are parameters and values to ensure that : http://example.com/file/id/2 will call file.php with id=2

To achieve that, only use some reg exp and design you "Request" class carefully. For that example over the "Request" class ought to provide both getRequestedAction() and getParameter(string parameter) techniques. The getRequestedAction() method is going to be used once the "Request" object is fully populated to be able to call the right file/action/method.

if you opt to populate the parameter variety of the request object with both reg exp around the URL along with a parsing from the _GET array, you might become so terrible where : http://example.com/file/id/2 is equivalent to http://example.com/file?id=2 (and both can function)

you are able to decide to ignore extensions (http://example.com/file.html is equivalent to http://example.com/file), or otherwise.

Finally, for many URL, you are able to decide to just ignore exactly what goes following the last '/'. To ensure that : http://example.com/question/3/where-is-khadafi is equivalent to http://example.com/question/3/is-linux-better-than-windows

Within the different file.php, only use $request->getParameter('id') to obtain the worth of the "id" parameter, rather than while using _GET or _Publish arrays.

The entire point would be to

  1. Redirect all incoming visitors to just one "front controller"
  2. For the reason that file, produce a "Request" object that consists of all of the informations required to run the website
  3. Call the right action (php file) in line with the informations contained for the reason that "Request" object
  4. Within the actions, make use of this request resist fetch the parameters included in the URL

Hope this can help

Note Google have stated they prefer news.php?id=$1 rather than news/$1 since it is simpler to allow them to identify the variable. This really is more pertinent when growing the amount of variables as just searching at the first example is a little confusing:


You could mix the 2 if a person parameter is generic just like a category:


You ought to really reexamine the look if several parameter is needed which is not really a temporary search.