douhuang3740 2013-11-15 22:04
浏览 53
已采纳

使用htaccess打开.html而不是php

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>
  • 写回答

3条回答 默认 最新

  • dpnru86024 2013-12-16 16:53
    关注

    Couldn't use the htaccess.
    I had to use the beforefilter within AppController.

    thanks

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line