Adventure,PHP,framework,page controller,front controller,pattern,object orientated design,software,development,reusability,uml,tutorial,benchmark,brilliant performance,

Search:    
Downloads  |  SVN!  |  Roadmap  |  Forum!  |  Bugtracking  |  Guestbook  |  Backlinks!  |  References!  |  Sitemap  |  Impress  
 
Deutsch | English Adventure PHP Framework  Bookmark @ Technorati Bookmark @ del.icio.us Bookmark @ Mr. Wong Bookmark @ Simpy Bookmark @ Google Bookmark @ Digg.com Adventure PHP Framework Print page 069-Url-rewriting

URL rewriting

Rank article:
This article has not yet been ranked. Vote this article first of all!

1. Introduction

The adventure php framework enables you, to operate web pages or applications in url rewrite mode or in normal mode. URL rewriting means, that URL params are separated by "/" instead of "&" and "=". This request layout pretends, that the requested ressource is located in a folder path. Another side effect is, that search engines tend to scan slash URLs more likely. Please note, that this technique does not supersede normal search engine optimization.


2. Configuration

If you use the URL rewrite mode, please be aware, that the bootstrap file (e.g. index.php) must be located in the DOCUMENT_ROOT of your webserver or any VHOST. Otherwise, the assignment of params and values can not be guaranteed.


2.1. Apache configuration

Using the URL rewrite mode a .htaccess file must be created. The following code box shows you an example, that can be used with the bigger part of your applications:
# start mod_rewrite
RewriteEngine on

# exclude some directories
RewriteCond %{REQUEST_URI} !^(\/frontend) [NC]

# define the rule itself. Every request that is not matching the exception list is
# redirected to the index.php file
RewriteRule !(index\.php|\.css|\.jpe?g|\.png|\.gif|\.ico)$ /index.php?query=%{REQUEST_URI}&%{QUERY_STRING} [NC,L]
Please note, that the definition
/index.php?query=%{REQUEST_URI}&%{QUERY_STRING}
must remain unaffected. It defines the param, that is used by the pagecontrollerRewriteRequestFilter and frontcontrollerRewriteRequestFilter to analyze the URL parameters and write them to the $_REQUEST-Array. The exception list
!(index\.php|\.css|\.jpe?g|\.png|\.gif|\.ico)$
can be manipulated as desired.


2.2. Framework configuration

To use the framework in URL rewriting mode it is necessary to switch the registry paramater URLRewriting in the apf::core namespace to true. This can be achieved by adding
   $Reg = &Singleton::getInstance('Registry');
   
$Reg->register('apf::core','URLRewriting',true); 
to your bootstrap file.


3. Usage of the URL rewriting

While using the URL rewriting mode, the following hints should be kept in mind:
  • Ressources like images, css files or java scripts must be addressed absolutely.
  • Modules, written for both modes must be aware of the two flavours. If you need to knwo about the current URL layout you can retrieve this information from the registry.
  • If you are using more than one bootstrap file, please add it to the exception list in the .htaccess file.

Comments

Do you want to add a comment to the article above, or do you want to post additional hints? So please click here. Comments already posted can be found below.


There are no comments belonging to this article.


Powered by WebRing.