2015-11-06 121 views
0

我正在为Web资源管理编写一个.htaccess文件。Apache RewriteRule模式

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

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

而且,我的重写规则如下。

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 "^.*/static/(.*)$" "resources/floworks-web-console-1.0/static/$1" [L] 

什么是问题?

附录

这是我的目录结构

网络基地 - /数据/网络
网站基地 - /数据/网站/店
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启动/店/ Web的控制台/静态
而且,另一种情况是通过使用到路由器脚本“重写规则。* route.php [L]”

+0

所以web控制台不是一个真正的目录? –

+0

是的,这不是一个真正的 – ordinaryparksee

回答

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] 
+0

对不起,它不起作用 – ordinaryparksee

+0

我需要更多的解释比不工作或我无法帮助您排除故障。什么不起作用?任何错误? .htaccess文件位于何处?你的资源目录在哪里,根目录下还是商店下? –

+0

哦,对不起,我的描述。我的意思是重写不能追上URI。如果这项工作显示了我的default.css文件内容,但它没有捕获和工作如下语句“RewriteRule。* route.php [L]”。 – ordinaryparksee

0

我发现自己。

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

我从L该标志更改为END
感谢。