user1766057
user1766057

Reputation: 21

CakePHP redirect to external source under same domain

I've developed (using CakePHP) and deployed a web site on an Apache server (not managed by me) which provides a use statistics service under http://www.domain.com/stats. How do I tell the routes.php (or where should it be done) to not try to link the '/stats' with a StatsController but instead show the page provided by Apache?

Upvotes: 2

Views: 216

Answers (1)

Lawrence Barsanti
Lawrence Barsanti

Reputation: 33222

Typically you put files in webroot when you want them to be accessible outside of cake. However, it sounds like this is not possible in your case. You could try adding a condition to the .htaccess file in the cake root directory.

<IfModule mod_rewrite.c>
   RewriteEngine on

   RewriteCond %{REQUEST_URI} !^/stats
   RewriteRule    ^$ app/webroot/    [L]

   RewriteCond %{REQUEST_URI} !^/stats
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

I haven't tested this but the idea is to prevent redirects if the path starts with /stats which will avoid cake.

See:

http://book.cakephp.org/2.0/en/installation/advanced-installation.html http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

Upvotes: 1

Related Questions