Creating beautiful URLs with Agile Toolkit

Tuesday, July 20th, 2010|Beginner tips, Version 3|by Romans

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

[php]
$config['url_postfix']=’.html’;
[/php]

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.

2 Comments

jancha
Posted July 23, 201010:23 am

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

romaninsh
Posted July 26, 20104:56 am

thanks! Good note.