2

Can I create a clean URL for WebBroker webpages/applications ?

A typical WebBroker URL normally looks like:

hxxp://www.mywebsite.com/myapp.dll?name=fred

or

hxxp://www.mywebsite.com/myapp.dll/names/fred

What I would prefer is:

hxxp://www.mywebsite.com/names/fred

Any idea how I can achieve this with Delphi/WebBroker ? (ISAPI/Apache)

BЈовић
  • 62,405
  • 41
  • 173
  • 273

1 Answers1

6

The typical way of doing this is to use apache's mod_rewrite to redirect requests to the url w/ parameters. Many, many applications do this to create 'human readable' and more search engine friendly urls.

For example, you might add this rule to make action=sales&year=2009 look like sales-2009.htm:

RewriteRule ^sales-2009.htm?$ index.php?action=sales&y=2009 [L]

When the user goes to 'sales-2009.htm', its actually redirected to the php page with the appropriate parameters. To the end user, though, it still displays sales-2009.htm in the browser's url bar.

You can, of course, use regular expressions w/ mod_rewrite, such that you can make the redirections much more flexible. You could, for example, make a single expression in the above example that would map any year to the correct parameter.

GrandmasterB
  • 3,396
  • 1
  • 23
  • 22
  • 2
    Rewriting urls is not only available on Apache, but on IIS as well. Certainly for IIS7. You just need to install the URLRewrite module as offered by MS itself. http://www.iis.net/download/URLRewrite – Marjan Venema Oct 14 '10 at 07:33