简体   繁体   中英

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. But actually all scripts are located in http://my.domain.com/js/script.js without XXX so i need to ignore this 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

You could use a .htaccess file in your application root that contains this

#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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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