0

i am implementing following solution for cache problem: How to force browser to reload cached CSS/JS files?

but browser not able to found my css file after change it's name. when i manually goes to open it, it gives 404 error.

here is my complete .htaccess code:

RewriteEngine on
RewriteBase /App
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]
RewriteRule ^(.*)\.[\d]{10}\.(css|js)$ $1.$2 [L]

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

My css file path is: /assets/master.css

basically what i want to do is dynamically rewrite all css & js files like this: master.1454667174.css to this: master.css

i want server to ignore that 10 digit number before file extension and return only master.css file to browser.

Please help..

Community
  • 1
  • 1
  • Possible duplicate of [Seo Friendly Url css img js not working](http://stackoverflow.com/questions/31241701/seo-friendly-url-css-img-js-not-working) – Amit Verma Mar 04 '17 at 17:02
  • basically what i want to do is dynamically rewrite all css & js files like this master.1454667174.css to this: master.css – Sanchit Patil Mar 04 '17 at 17:25

1 Answers1

1

url rewriting should affects your file path. You have to put a '/' to the css or js file path. Example:Your Original file path ->    css/style.css

You have to do ->    /css/style.css

this is as same as for js and image path..

(or)

you have to put the base url link in your head tag

https://www.w3schools.com/tags/att_base_href.asp

refer this to get the base url html syntax

Janen R
  • 729
  • 10
  • 21