Apache RewriteRule模式

时间:2015-11-06 14:21:03

标签: apache .htaccess mod-rewrite

我为网络资源管理编写.htaccess文件。

我想将这种URI模式用于静态资源

^.*/web-console/static/(.*)$

而且,我的RewriteRule在下面。

RewriteRule "^.*/web-console/static/(.*)$" "resources/floworks-web-console-1.0/static/$1" [L]

并且,我在URI下面请求

http://myhost/shop/web-console/static/css/default.css

但是Apache服务器没有匹配URI 如果我删除" / web-console" Apache运行正常 以下是RewriteRule

RewriteRule "^.*/static/(.*)$" "resources/floworks-web-console-1.0/static/$1" [L]

什么问题?

附录

这是我的目录结构

网络基础 - / data / web
网站基础 - / data / web / shop
htaccess - /data/web/shop/.htaccess
路由器脚本 - /data/web/shop/route.php
静态资源 - /data/web/shop/resources/floworks-web-console-1.0/static
css文件 - /data/web/shop/resources/floworks-web-console-1.0/static/css/default.css

所以,如果启动URI,我希望响应静态资源/ shop / web-console / static
而且,其他情况是使用" RewriteRule传递给路由器脚本。* route.php [L]"

2 个答案:

答案 0 :(得分:0)

你应该能够这样做。如果您在子文件夹shop中有此.htaccess,则应添加rewritebase。

RewriteEngine On
RewriteBase /shop/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule "^web-console/static/(.*)$" "resources/floworks-web-console-1.0/static/$1" [L]

答案 1 :(得分:0)

我找到了自己。

RewriteRule "web-console/static/(.*)$" "resources/floworks-web-console-1.0/static/$1" [END]

我会将该标记从L更改为END
感谢。