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:
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 »
Leave a Reply
-
Recent
- You have missed few posts!
- ATK4 Blog moved to its own domain. Please update.
- Checking password strength with CrackLib
- Creating beautiful URLs with Agile Toolkit
- Security model
- New features of DB and dsql planned for ATK 4.0
- Lightweight CMS in ATK (video)
- Reloading…
- Symfony 2.0 vs ATK3.8 – part 5 – Architecture and beyond
- Symfony 2.0 vs ATK3.8 – part 4 – Bundles, Users, DB
- Symfony 2.0 vs ATK3.8 – part 3 – The Controller
- Symfony 2.0 vs ATK3.8 – part 2 – The View
-
Links
-
Archives
- August 2010 (1)
- July 2010 (3)
- June 2010 (4)
- May 2010 (9)
- April 2010 (12)
-
Categories
-
RSS
Entries RSS
Comments RSS
change ^project/(.+)/$ to ^project/(.+)(/|)$ to enable support for both with and without trailing slash
thanks! Good note.