简体   繁体   English

如何在Yii中忽略部分URL

[英]how to ignore part of URL in Yii

In my project all js and css url is look like http://my.domain.com/XXX/js/script.js were XXX - is a version of release wich is incrementing with each commit to master. 在我的项目中,所有js和css URL都看起来像http://my.domain.com/XXX/js/script.js都是XXX-是每次向master提交时都会增加的发行版。 But actually all scripts are located in http://my.domain.com/js/script.js without XXX so i need to ignore this XXX. 但是实际上所有脚本都位于没有XXX的http://my.domain.com/js/script.js中 ,因此我需要忽略此XXX。 How i can do it. 我该怎么做。 Trying to do it with url manager, but without result. 尝试使用网址管理器执行此操作,但没有结果。 It was done, because of CDN is ignoring ?V=XXX at the end of links and returns all cached results 这样做是因为CDN在链接末尾忽略了?V = XXX并返回所有缓存的结果

You could use a .htaccess file in your application root that contains this 您可以在包含以下内容的应用程序根目录中使用.htaccess文件

#Forward all non-existent files/directories to Yii
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) XXX/index.php/$1 [QSA,L]

edit: 编辑:

after understanding the question, i think you should have a post-commit hook on your versioning system that changes the XXX in your .htaccess file 在理解了问题之后,我认为您应该在版本控制系统上有一个提交后的钩子,该钩子可以更改.htaccess文件中的XXX。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM