我为我的网站准备了一个现成的主题。我需要将 images/js/css 文件夹移动到特定文件夹。
目前是这样的:
|- application
|- assets
|- img
|- css
|- js
|- system
主题是 img/css/js 文件夹位于根文件夹中。
为了将请求路由到 img/css/js 文件夹,我在我的.htaccess
文件中写了一些类似的东西。
RewriteEngine On
RewriteCond $1 !^(images|robots\.txt|assets)
RewriteRule img/(.*) /assets/img/$1 [L]
RewriteRule js/(.*) /assets/js/$1 [L]
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]
但我注意到发生了递归。从
[Fri May 03 11:56:46 2013] [error] [client 127.0.0.1] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
我怎么能避免递归。我注意到更改文件夹名称有帮助,但更喜欢通过.htaccess
.
我不太擅长正则表达式,但我记得有办法在其中说 NOT。比如说redirect urls comming for 'img' folder but NOT having 'assets' in it should be redirected to 'assets/img' folder.
顺便说一句,您知道这些.htaccess
规则在性能方面的成本有多大。我的意思是,拥有它是不是一个坏主意等等。
在此先感谢,祝您有美好的一天。