开发者

Can I create a clean URL using WebBroker and Delphi?

开发者 https://www.devze.com 2023-01-20 12:39 出处:网络
Can I create a c开发者_StackOverflow社区lean URL for WebBroker webpages/applications ? A typical WebBroker URL normally looks like:

Can I create a c开发者_StackOverflow社区lean 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)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号