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.
7 Comments
Rahhhh I tried so much to make this work !! thanks !!
I had that problem with my phpmyadmin directory …
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.
what to do if it is not working? I tried couple ways to make it working bot I failed
@korki: What is the problem?
it’s not working, i have a statistics from my hosting provider and i did exactly what you wrote and it’s not working
@korki: It is possible that you have to add additional rules. My hosting provider is Dreamhost, and I need two rules to access the statistics:
RewriteCond %{REQUEST_URI} ^/stats/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/failed_auth.html$
2 Trackbacks/Pingbacks
[...] 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: [...]
[...] 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: [...]