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..

2
  • Possible duplicate of Seo Friendly Url css img js not working Commented Mar 4, 2017 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 Commented Mar 4, 2017 at 17:25

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.