Take over the “control” of some urls from CakePHP
By default, CakePHP takes full “control” of all URLs at the point where it is installed. Sometimes that behaviour is not desired. For example, my hoster defines an url like mydomain.com/stats where the statistics are available. If I install CakePHP in the root, this url no longer works resp. causes an error in CakePHP. The solution is to modify the .htaccess file in app/webroot. The original .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
And after the modification:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/stats/(.*)$
RewriteRule ^.*$ - [L]
</IfModule>
# Begin CakePHP
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
The added rule is rather simple: if the url starts with /stats stop the interpretation of the .htaccess file. That’s it.




Rahhhh I tried so much to make this work !! thanks !!
I had that problem with my phpmyadmin directory …
[...] Daniel Hofstetter (cakebaker): Take over the “control” of some urls from CakePHP: ”By default, CakePHP takes full ‘control’ of all URLs at the point where it is installed. Sometimes that behaviour is not desired. For example, my hoster defines an url like mydomain.com/stats where the statistics are available. If I install CakePHP in the root, this url no longer works resp. causes an error in CakePHP. The solution is to modify the .htaccess file in app/webroot. The original .htaccess file: [...]
Hmm..Didn’t need that in DH, stats/ and dh_phpmyadmin/
@oth: Hm, I’m also on DH, but for some reason I have to modify the htaccess file in a way similar to the one shown above to access the statistics.
[...] Take over the “control” of some urls from CakePHP August 29th 2006 Posted to Internet Clipping, CakePHP http://cakebaker.wordpress.com/2006/08/17/take-over-the-control-of-some-urls-from-cakephp/ By default, CakePHP takes full “control” of all URLs at the point where it is installed. Sometimes that behaviour is not desired. For example, my hoster defines an url like mydomain.com/stats where the statistics are available. If I install CakePHP in the root, this url no longer works resp. causes an error in CakePHP. The solution is to modify the .htaccess file in app/webroot. The original .htaccess file: [...]
I had the same problem like oth’s and I solved it by modifying not /app/webroot/.htaccess but rather /.htaccess (the htaccess file in the project root).
THANKSS SOOO MUCH for this post, Ive been going crazy with this for the last few days.
@Walid: I am glad it was useful for you :)