Reputation: 4928
I am using cakephp and now I need to do a inner redirect to an .html if the file exists inside a cache folder.
So, lets say there is a controller CTRL and action ACT, the url for it is:
domain.com/ctrl/act
Now, I want my htaccess to check if there is an .html inside teh cache folder with the same name of the controller and the action, like:
/cache/ctrl/act.html
if the file exists, just send it and don't touch the php.
I got it to work but now the cakephp is not being processed, the server returns a 500 error.
Can you please help me with this. I also need to check if there is an /index.html within the cachefolder/ctrl/ because the links sometimes has only the controller name.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI}.html !^/cache
RewriteRule ^(.*)$ cache/$1.html [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Upvotes: 0
Views: 262
Reputation: 4928
Couldn't use the htaccess.
I had to use the beforefilter within AppController.
thanks
Upvotes: 0
Reputation: 786289
Change your first rule to this rule:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/app/webroot/cache/$1.html -f
RewriteRule ^(.+?)/?$ cache/$1.html [L]
Upvotes: 1
Reputation: 189
Add following in routes.php
Router::parseExtensions('html');
This will strip off the .html so cakePHP can just work 'normal'
Upvotes: 0