您的位置:首页 > 运维架构 > Apache

Apache htaccess 重写假设文件存在!

2016-01-30 13:11 513 查看
假设文件 data/cache/index.html 存在。那么才重写。

否则使用默认的MVC 重写。by default.fu@foxmail.com

RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/data/cache/list_1.html -f
RewriteRule ^game\/?

$ data/cache/list_1.html [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/$1 [PT,QSA,L]
RewriteRule ^(.*)$ index.php?/$1 [PT,QSA,L]


—————————————————————增强版 正则文件存在就重写 by default.fu@foxmail.com———————————————————

RewriteEngine on

RewriteCond %{DOCUMENT_ROOT}/demo/cache/game_$1.html -f
RewriteRule ^game\/(\d+)\/?$ cache/game_$1.html [L]

RewriteCond %{DOCUMENT_ROOT}/demo/cache/game.html -f
RewriteRule ^game\/?$ cache/game.html [L]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: