I'm trying to integrate CakePhp into an existing PHP application. Due
to the "not a file" RewriteCond statement in the .htaccess file in
/webroot, if I have a php file /webroot/noncake.php, then going to
www.example.com/noncake.php will get me that file without running any
cake code.
What I'd like to do is have all requests for *.php files map to a
default controller, say PhpFilesController, which would then render the
requested php file within the default layout as if it were a view file.
This is somewhat similar to the way the PagesController renders thtml
files in /views/pages/. The difference is that I'd like to be able to
map requests for .php files anywhere under /webroot to a similar
controller which would essentially include the requested php file as if
it were a normal view.
The reason is that I'd like to be able to render these php files, which
are essentially legacy content on the site, within a customizable
layout that renders other elements such as a per-user customizable
navigation bar.
So far I've managed to get all requests for *.php files to map to the
standard /webroot/index.php?url=(original url) like standard cake-bound
requests are mapped. I just added the following to /webroot/.htaccess:
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.php)$ index.php?url=$1 [L]
This worked, with http://example.com/test.php leading me to a standard
Cake 404 page that reads The requested address test.php was not found
on the server. Then I tried adding a
$Route->connect('/*.php', array('controller' => 'pages', 'action' =>
'display'));
in hopes that I might somehow get to the pages controller. But no luck
- i still get the 404 error and the request never reaches the pages
controller. Any ideas as to why this route->connect statment is
ineffectual? For reference, the 404 error is thrown on line 97 of the
Dispatcher::dispatch function, located at
http://api.cakephp.org/dispatcher_8php-source.html
Can anyone suggest what kind of Routing or other technique I'd need to
use to make this mapping possible? Once I get this working I'm also
going to need to get requests for www.example.com/adirectory/ to do the
same thing only for /adirectory/index.php, which require even more
mod_rewrite and routing stuff.
Thanks so much,
Dan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---