1

谢谢阅读。首先,我在根目录中有一个 .htaccess ,其中包含以下语句:

# Mod Rewrite
<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteRule     ^$              /root/              [L]
    RewriteRule     (.*)            /root/$1            [L]
</IfModule>

在根文件夹中我得到了这个文件:

# Mod Rewrite
<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^(.*)$          /root/index.php/$1 [PT,L]
</IfModule>

此外,在文件夹/root中,我有三个文件夹cssjsimages.

我的应用程序设计为与我的 MVC 框架分离(有点像 CodeGgniter)。所以这是树:

- application
    - my application files are there
- root
    - css
    - js
    - images
- grecko
    - my mvc framework files are there

像这样,我可以在不触及应用程序文件夹下运行的整个网站的情况下更新我的框架。

无论如何,我现在想做的就是将我上面说的三个文件夹(cssjsimages)移动到里面/application/assets/。但由于所有内容都被重定向到/root/,我需要一个允许将这样的请求http://www.domain.tld/css/blabla.css映射到/application/assets/css/blabla.css等的规则。

我确实尝试过,但没有成功。

谢谢。

4

2 回答 2

1

试着把它放在你的 web 根目录(不是根文件夹)的 .htaccess 中:

RewriteEngine on

RewriteRule ^(css|js|images)(.*) application/assets/$1$2 [L]

RewriteCond %{REQUEST_URI} !^/application/assets [NC]
RewriteRule (.*) root/$1 [L]

避免多余的空间。

于 2012-05-31T19:27:15.960 回答
1

将此代码放入$DOCUMENT_ROOT/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /

    RewriteRule ^(css|js|images)(/.*|)$ application/assets/$1$2 [L,NC]

    RewriteCond %{ENV:REDIRECT_STATUS} !200
    RewriteRule ^ root${REQUEST_URI} [L]
</IfModule>
于 2012-05-31T20:32:41.277 回答