I found this question:
and it was useful but i'm not able to write code for my system.
This is my URL structure:
www.example.com/typeOfPost/category/ID/permalink
(For example: www.example.com/news/sport/8734/here-goes-article-title
)
My cache structure is this:
ROOT/cache/responsive/ID/typeOfPost/category/permalink
where permalink
is a file without extension that contains the html code of the page.
Unfortunately for cache file I can't use the same URL structure so I don't know how to check if cache file exists and if so load it, otherwise load data from database.
At the moment I'm reading checking for cache file via PHP and if it exists I load it otherwise I load data from database.
For server performance I'd like to to bypass PHP and check for cache file via Apache, I think this is the right approach... isn't it? If so, how can I write the .htaccess
file?
This is the code i wrote but it doesn't work:
RewriteCond %{DOCUMENT_ROOT}/cache/responsive/([0-9]+)/([^/]+)/([^/]+)/([^/]+) -f
RewriteRule ^([^/]+)/([^/]+)/([0-9]+)/([^/]+)$ /cache/responsive/$3/$1/$2/$4 [L]