Agile Toolkit news

library updates, tips, information and more

Creating beautiful URLs with Agile Toolkit

By default pages created with Agile Toolkit end with .html. I myself believe that this is a good extension because HTML is being passed over. However it is easy to use different URLs in Agile Toolkit, here is how

$config['url_postfix']='.html';
First you can change this config setting. It is .html by default, but you can set it to .php, or even .jsp or simply ‘/’ (ruby-style). This affects how pages are being built. However if you are passing any GET arguments they will be appended through ?arg=val.
If you are willing to put some of the data inside the URL, for instance:
http://www.agiletech.ie/blog/10-good-saas-tips/
then there is a very good way – mod_rewrite. Agile Toolkit is using original URL to determine page name, however you can re-define which page handles what in .htaccess file. Here is sample .htaccess which we use on our homepage:
RewriteRule     ^project/(.+)/$            main.php?page=project&url=$1   [L]
RewriteRule     ^project/(.+)$            main.php?page=project&url=$1   [L]
RewriteRule     ^news/?$            main.php?page=news&url=$1   [L]
RewriteRule     ^news/([0-9]{4})/?$ main.php?page=news&y=$1   [L]
RewriteRule     ^news/[0-9]+/([a-zA-Z0-9_-]+)/?$        main.php?page=news_view&url=$1   [L]
RewriteRule     .html$            main.php   [L]
RewriteRule     ^[^.]*$            main.php   [L]
RewriteRule     /[^.]*$            main.php   [L]
We want to satisfy project links using format with or without trailing slash. I’m sure it’s possible to write that in a single line with fancier regexp. This allows us to have the following URLs:
where part of the URL is actually passed as an argument to the script.
Try this yourself and let me know how this works out.
About these ads

July 20, 2010 - Posted by | Beginner tips, Version 3

2 Comments »

  1. change ^project/(.+)/$ to ^project/(.+)(/|)$ to enable support for both with and without trailing slash

    Comment by jancha | July 23, 2010 | Reply

    • thanks! Good note.

      Comment by romaninsh | July 26, 2010 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.