Title: Manually rewrite css link?
Last modified: August 20, 2016

---

# Manually rewrite css link?

 *  [Qcybb](https://wordpress.org/support/users/qcybb/)
 * (@qcybb)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/manually-rewrite-css-link/)
 * When the option “Rewrite URL structure” is enabled in the “Minify” tab, for some
   reason the plugin refuses to create the .css file.
 * However with that option disabled, it saves the minified file without issues.
 * What I would like to do is keep the option disabled – but rewrite the .css file
   link (in the header) myself. That way the plugin keeps working and I am able 
   to use my CDN for the css file.
 * What I have tried is :
 *     ```
       function change_stylesheet_loc($uri)
       {
           $uri = str_replace('example.com', 'cdn.example.com', $uri);
           $uri = str_replace('index.php?file=', '', $uri);
           return $uri;
       }
       add_filter('stylesheet_uri', 'change_stylesheet_loc', 20000);
       ```
   
 * The code above should have change this :
 * [http://example.com/wp-content/w3tc/min/index.php?file=6fb9f/default.include.c95d49.css](http://example.com/wp-content/w3tc/min/index.php?file=6fb9f/default.include.c95d49.css)
 * To this :
 * [http://example.com/wp-content/w3tc/min/6fb9f/default.include.c95d49.css](http://example.com/wp-content/w3tc/min/6fb9f/default.include.c95d49.css)
 * Do I need to use a different filter hook than “stylesheet_uri”? Does W3 Total
   Cache have it’s own filter hook I can use?
 * [http://wordpress.org/extend/plugins/w3-total-cache/](http://wordpress.org/extend/plugins/w3-total-cache/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [amitbhatia](https://wordpress.org/support/users/amitbhatia/)
 * (@amitbhatia)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/manually-rewrite-css-link/#post-3343401)
 * Why don’t you test it out and report back?
 *  Thread Starter [Qcybb](https://wordpress.org/support/users/qcybb/)
 * (@qcybb)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/manually-rewrite-css-link/#post-3343492)
 * I did test it out – and it doesn’t work.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Manually rewrite css link?’ is closed to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

## Tags

 * [css](https://wordpress.org/support/topic-tag/css/)
 * [filter](https://wordpress.org/support/topic-tag/filter/)

 * 2 replies
 * 2 participants
 * Last reply from: [Qcybb](https://wordpress.org/support/users/qcybb/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/manually-rewrite-css-link/#post-3343492)
 * Status: not resolved