I'll admit I'm brand brand new to coding. I am trying to help a client who uses Dreamweaver to publish their website on a server at their headquarters. I asked their IT department to add code to their .htaccess file that would help redirect non https to https and force www but also remove the .html extensions. I am pretty sure the code is correct but when they added it, the site broke.
The old .htaccess file had the following code:
/var/www/html/HRT/.htaccess
RedirectMatch 301 ^/here(/.+?)?$ http://go.example.com/here
RedirectMatch 301 ^/HERE(/.+?)?$ http://go.example.com/here
RedirectMatch 301 ^/there(/.+?)?$ http://go.example.com/there
RedirectMatch 301 ^/THERE(/.+?)?$ http://go.example.com/there
I changed the urls for privacy. Just having this worked before. But when I asked them to add the below code, it broke. Not sure even where to start.
# FORCE HTTPS, FORCE WWW and REMOVE HTML #
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]
RewriteRule ^([^/]+)\.html$ $1 [QSA,L]
# EXPIRES CACHING VIA HTACCESS #
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
I should note that during the previous week they added to their http.config file for expiring cache too so I'm not sure that would cause this problem. Just trying to think of all the things they've done before this error.
Thanks in advance.
RewriteRule ^([^/]+)\.html$ $1 [QSA,L]
You can't simply "remove" the .html file extension like that in .htaccess - it will most certainly break your site.
In fact, you can't remove the file extension by editing .htaccess alone. It's a two stage process:
You need to remove the .html extension on all your URLs - in your application. All your internal links need to be updated to omit the .html extension.
You then use .htaccess to internally rewrite the request without an extension, back to the real filesystem path that includes the .html extension. Underneath it all, your filesystem paths have not changed.
For example:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.html [L]
This assumes that your URLs do not otherwise contain dots (.) - except if they are requesting a file directly (eg. .js, .css, .jpg, etc.)
You will also need to ensure that MultiViews is disabled (if not already) for this to work properly. ie. Include the following at the top of your .htaccess file:
Options -MultiViews
If you are changing an existing URL structure then you'll need to implement an external redirect to physically remove the .html extension from the URL in order to preserve SEO. However, you should only implement this if you have completed step #1 (and #2) above and removed the .html extension on all your internal URLs (otherwise your users will suffer an external redirect on every link when navigating your site, which will be slow and double the requests hitting your server).
For example, the following redirect would need to go before the rewrite (above):
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule (.+)\.html$ /$1 [R=302,L]
The condition that checks against the REDIRECT_STATUS environment variable ensures that we target only direct requests and not the rewritten request.
Note that this is currently a 302 (temporary) redirect. Only change it to a 301 (permanent) redirect once you have confirmed that it works OK - in order to avoid caching issues.
In Summary
# Disable MultiViews
Options -MultiViews
Then add the following below your canonical HTTP to HTTPS and non-www to www redirects:
# Redirect to remove the ".html" extension from direct requests
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule (.+)\.html$ /$1 [R=302,L]
# Internal rewrite to re-append the ".html" extension for the internal request
# NB: Exclude requests for directories
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.html [L]
Related
So it redirects to https but as I don't have SSL certificate anymore it needs to be disabled, tried to remove the Force SSL part didn't do anything same for the force web www didn't do any change either
another thing is when I go to my site it automatically adds www. twice so wwww.www.(domainname)
here's the htaccess
<IfModule mod_expires.c>
ExpiresActive on
# Your document HTML
ExpiresByType text/html "access plus 0 seconds"
# Media: images, video, audio
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
# CSS and JavaScript
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
</IfModule>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
### Force web (www) on all URLs
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
### Force SSL (https) on all URLs
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
### Remove trailing slash from all URLs
RewriteRule ^(.*)/$ $1 [R=301,L]
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
RewriteRule ^buy-([a-z0-9-]+)$ buy.php?game=$1 [NC,L,QSA]
# Redirect proper URL to SEO-friendly for buy.php
RewriteCond %{THE_REQUEST} buy\.php\?game=([a-z0-9-]+)\s [NC]
RewriteRule ^ buy-%1? [R=301,L]
# Internally link SEO-friendly with proper URL for buy.php
RewriteRule ^buy-([a-z0-9-]+)$ buy.php?game=$1 [L]
# Redirect proper URL to SEO-friendly for sell.php
RewriteCond %{THE_REQUEST} sell\.php\?game=([a-z0-9-]+)\s [NC]
RewriteRule ^ sell-%1? [R=301,L]
# Internally link SEO-friendly with proper URL for sell.php
RewriteRule ^sell-([a-z0-9-]+)$ sell.php?game=$1 [L]
# Redirect proper URL to SEO-friendly for testimonials.php (with pages)
RewriteCond %{THE_REQUEST} testimonials\.php\?page=([0-9-]+)\s [NC]
RewriteRule ^ testimonials/%1? [R=301,L]
# Internally link SEO-friendly with proper URL for testimonials.php (with pages)
RewriteRule ^testimonials/([0-9-]+)$ testimonials.php?page=$1 [L]
# Redirect proper URL to SEO-friendly for recover.php (with code)
RewriteCond %{THE_REQUEST} recover\.php\?code=([a-z0-9-]+)\s [NC]
RewriteRule ^ recover/%1? [R=301,L]
# Internally link SEO-friendly with proper URL for recover.php (with pages)
RewriteRule ^recover/([a-z0-9-]+)$ recover.php?code=$1 [L]
# Redirect proper URL to SEO-friendly for index.php (with order ID)
RewriteCond %{THE_REQUEST} index\.php\?order=([a-zA-Z0-9-]+)\s [NC]
RewriteRule ^ o/%1? [R=301,L]
# Internally link SEO-friendly with proper URL for index.php (with order ID)
RewriteRule ^o/([a-zA-Z0-9-]+)$ index.php?order=$1 [L]
# Redirect proper URL to SEO-friendly for any standard page
RewriteCond %{THE_REQUEST} \s/+(account|testimonials|contact|privacy|terms|cart|recover|faq|login|register|banned)\.php [NC]
RewriteRule ^ /%1? [R=301,L]
# Internally link SEO-friendly with proper URL for any standard page
RewriteRule ^(account|testimonials|contact|privacy|terms|cart|recover|faq|login|register|banned)$ $1.php [NC,L]
It is likely that you had a 301 redirect from http to https in your configuration. Simply removing this redirect and retrying will not help since 301 is the code for a permanent redirect which means that the browser will remember this redirect, i.e. it will visit https:// instead of http:// since the cached redirect says so and will not even try to visit http://.
To fix this you need to have both the redirect removed and the browser cache cleared - and then can you retry. And yes, this affects every client which has visited your site. Since you cannot clear the browser cache from every client you better install a new certificate. Once you have one you can redirect all users from https:// to http:// and after a while most browsers should have gotten the message that http:// is the way to go so that you can remove the redirect and the certificate. Or even better, just stay with https:// - there are CA like Let's Encrypt which provide you with free certificates.
I am fighting on one Domain already quite a while with its .htaccess rules. I have found the rules I needed to redirect all non-existing files and folders and got it to work after i change its position in the .htaccess to top, so that my .htaccess looks now like this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ / [R=301,L]
</IfModule>
#Rewrite for non www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/? [R=301,L]
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} acer|alcatel|amoi|android|asus|avantgo|benq|blackberry|blazer|boxee|bravia|cdm-|ce-html|compal|(core|gom|m|vlcmedia|windows-media)player|dlna|docomo|dreambox|elaine|ericsson|fennec|flycast|foobar2000|google\ wireless\ transcoder|googlebot-mobile|googletv|gt-|hbbtv|hiptop|htc|huawei|iemobile|im-|ipad|ipaq|iphone|ipod|iris|itunes|kindle|large|lg(-|\/|_|1|2|3|4|5|6|7|8|9|e|http)|lenovo|levis|maemo|midp|miro|mmp|mot-|mobile|motorola|msn.*tv|mtv|nettv|nexus|nintendo|nokia|opera\ (mobi|mini)|palm|panasonic|pantech|pg-|philips|pixi\/|playstation|plex|plucker|pocket|portalmmm|pre\/|psp|quicktime|qtek|rim|sagem|samsung|sanyo|sch-|screen|sec-sgh|sendo|sfr|sgh-|sharp|sie-|smart(hub|phone|.?tv)|sonyericsson|sph-|sprint|spv|swisscom|symbian|t-mobile|tablet|toshiba|touch|treo|upnp|up.browser|vertu|videoweb|vk-|vodafone|volksbox|wafa|wap|webos|webtv|wii|windows\ (ce|phone)|wml|wonu|xbmc|xbox|xda|xiino|zte|zune [NC]
RewriteRule ^(.*)$ http://www.domain.tld/m/ [L,R=302]
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
<IfModule mod_deflate.c>
<filesMatch "\.(js|css|html|php|jpg|jpeg)$">
SetOutputFilter DEFLATE
</filesMatch>
</IfModule>
My problem is that my subfolders would need its own redirect rules for non-existing files/folders. I do not want them to be redirected to the root, but rather to their correct index'folder'.
The Site is build like this:
http://www.domain.tld/ <-- Mainsite
http://www.domain.tld/keywordX/1/ <-- Index folder for keyword X
http://www.domain.tld/keywordY/1/ <-- Index folder for keyword Y
http://www.domain.tld/keywordZ/1/ <-- Index folder for keyword Z
After I had added the rules to redirect all non-existing files/folders from root it also redirects my non existing files/folders in the Subfolders to the root too.
I have change the First Part of my .htaccess afterwards in a way i found to exclude directories, but that ended in a redirect error:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(keywordX|keywordY|keywordZ)($|/) - [L]
RewriteRule ^(.*)$ / [R=301,L]
</IfModule>
Any suggestion how i can avoid this behavior?
The following i have tried to add in the htaccess in /keywordX/ folder as also in the /keywordX/1/ folder:
I had found that adding an "RewriteEngine On" would do the trick. But it didn't.
I found that Line 1 RewriteEngine Off and Line 2 RewriteEngine On would work, but it also didn't.
Update 3:
The first time the site is loading properly AND the most redirects for the root are working. All existing folders are NOT redirected (No idea why it is not redirecting them as they are not excluded), but so far kproxy shows me kategoryX/kategoryY/kategoryZ are loading as they should.
It looks like i was with my previous tryouts on the right path, just that my file exclusion was incorrect. But after more and more reading and slowly but steadily getting more angry, i stumbled upon file extension exclusion.
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(images)/ [NC]
RewriteCond %{REQUEST_URI} !\.(xml|txt|css)$
RewriteRule ^.+$ / [R=302,NC,L]
With this bit of Code i was able to redirect all incorrect FOLDER request back to root.
What now is missing, is a redirect for incorrect files (what are the major part of the redirects) ... files like 123_itemname.html, 456_itemname.html and so on.
Is there a way to extend the htaccess code that i am using right now, or do i need to have a complete new approach?
Edit: I have made a lot of editing to the Question as i just couldn't wait and let someone else figure out whats wrong.
I have redirected all non www to www url using the following
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Next ,
The final url for categories required is :
http://www.slidecorner.com/category/Design
I have used this for achieving this
RewriteRule ^/?category/(.*) category.php?ctitle=$1
This also works, but when i check this url in any redirect checking websites , the "www" version of url is perfect, but "non www" url internally redirects to :
http://www.slidecorner.com/category.php/Design?ctitle=Design
Is this good for a search engine ? Please advise
Update : Tried [L] flag also , and rewritebase is already there. Attached full htaccess for reference
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^docs$ docs.php
RewriteRule ^category$ category.php
RewriteRule ^categories$ categories.php
RewriteRule ^members$ members.php
RewriteRule ^upload$ upload.php
RewriteRule ^search$ search.php
RewriteRule ^account$ account.php
RewriteRule ^logout$ logout.php
RewriteRule ^login$ login.php
RewriteRule ^signup$ signup.php
RewriteRule ^feeds$ feeds.php
RewriteRule ^mydocs$ mydocs.php
RewriteRule ^myfav$ myfavoritedocs.php
RewriteRule ^doc/(.*)/(.*) viewdoc.php?did=$1&title=$2
RewriteRule ^syndicate/docs/(.*)/(.*) syndicatedocs.php?filter=$1&title=$2
RewriteRule ^download/doc/(.*)/(.*) downloaddoc.php?DID=$1&title=$2
RewriteRule ^resetpassword/(.*) resetpassword.php?code=$1
RewriteRule ^confirmemail/(.*) confirmemail.php?code=$1
RewriteRule ^resendconfirmation/(.*) resendconfirmation.php?userid=$1
RewriteRule ^members/profile/(.*)/(.*) memberprofile.php?pid=$1&username=$2
RewriteRule ^/?category/(.*) category.php?ctitle=$1 [L]
# to hide jpg images
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?slidecorner.com[NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?slidecorner.*$ [NC]
RewriteRule \.(jpeg|jpg)$ - [F]
# to hide jpg images
# for sending compressed data to load faster
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
# for sending compressed data to load faster
</IfModule>
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
#non www redirect ,since the above doesnt redirect
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
<IfModule mod_security.c>
# Turn off mod_security filtering.
SecFilterEngine Off
# The below probably isn't needed,
# but better safe than sorry.
SecFilterScanPOST Off
</IfModule>
Options -Indexes
Update : I found the issue is due to this code
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
I removed that and the url is fine . Also the non www to www redirection is completely stopped because i removed that
Is there anything wrong with the above code ?
The order of directives (within modules) matters in .htaccess. Whilst your question suggests you are performing the canonical www redirect first, you actually have this after the internal rewrites in your .htaccess files and this is certainly a problem in this case. (Although the exact output you are getting from the "checking tool/website" would seem to be a fault of the "tool" IMO.)
Generally, you should always have external redirects before internal rewrites.
With the internal rewrite first you ending up losing your "pretty URL". What actually happens when you access the non-canonical (non-www) URL http://example.com/category/Design is:
Internal rewrite to:
/category.php?ctitle=Design
External redirect to:
http://www.example.com/category.php?ctitle=Design
It is important to realise that the L (last) flag only halts the current processing of the rule set. If an internal or external redirect has occurred then process starts again!
lets say my domain page is
www.website.com/about
and then a user puts
www.website.com/about/ (a trailing slash) at the end
it returns the same page, great. However search engines may see this as duplicate content as it could be seen as 2 pages.
if the user puts a trailing slash at the end of a page i want them to do a 301 redirect to the correct page.
my .htaccess file looks like this
# Begin cache control #
ExpiresActive on
ExpiresDefault "now plus 1440 minutes"
ExpiresByType text/html "now plus 1440 minutes"
<FilesMatch "\.(css|png|bmp|ico|htm|gff|html|js|jpg|jpeg|gif|gcf)$">
FileETag MTime Size
ExpiresDefault "now plus 1440 minutes"
</FilesMatch>
# End cache control #
Options +FollowSymLinks -MultiViews
AddOutputFilterByType DEFLATE text/html image/png image/jpeg image/jpg text/css text/javascript
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*?)/?$ $1.php [L,NC]
Does any one know how I can achieve this as everything im trying will not work.
You can insert this rule just before your last rule to remove trailing slash:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=302,NE,L]
I am trying to combine two .htaccess files into one:
https://github.com/silverstripe/silverstripe-installer/blob/3.1/.htaccess
AND
https://github.com/jkphl/squeezr/blob/master/.htaccess
I also want to exclude the CMS from any squeezr rules (i.e. links to http://www.mysite.co.nz/admin/.... should not run via squeezr.
Is it sufficient to basically combine the two .htaccess files and write the final redirection rule for silverstripe as follows:
RewriteRule (?!^squeezr|admin)^.*$ framework/main.php?url=$1 [L,QSA,NC]
Please let me know if you need more information in this question and I will add.
You should be able to just combine the 2. There doesn't seem any conflict
https://gist.github.com/24b48c12d82c73e60a37
EDIT:
In your question you also mention that you want to exclude the cms from sqeezer, the idea makes sense, however, the RewriteRule you have posted does not at all, in fact I would be surprised if that did not throw an error.
The only thing the above rule would do (if it would work), would be to exclude squeezr files from being rewritten to framework, but that would never happen anyway, because the RewriteConds before would already deny that (SilverStripe does not rewrite existing files).
so what you need to do is actually add a RewriteCond to the 2 squeezr rules, to tell them not to use cms and framework.
I believe adding the 2 following conditions (right before the squeezr rules) would do that:
RewriteCond %{REQUEST_URI} !cms # exclude the silverstripe cms
RewriteCond %{REQUEST_URI} !framework # exclude the silverstripe framework which is by
(you can also view it as diff for the gist here: https://gist.github.com/Zauberfisch/d681474df67ced83ec1f/revisions)
the full config file:
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html
<Files *.ss>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files>
<Files web.config>
Order deny,allow
Deny from all
</Files>
<Files ~ "\.ya?ml$">
Order allow,deny
Deny from all
</Files>
<IfModule mod_rewrite.c>
Options +FollowSymlinks
# Start the rewrite engine
RewriteEngine On
RewriteBase /
# REDIRECT ANY DIRECT IMAGE REQUEST TO A CACHED VERSION
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{ENV:REDIRECT_BREAKPOINT} !\d+px
RewriteCond %{QUERY_STRING} !^([^&]*&)*squeezr=(0|false|no)
RewriteCond %{HTTP_COOKIE} squeezr.images=(\d+px) [NC]
RewriteCond %{REQUEST_URI} !cms # exclude the silverstripe cms
RewriteCond %{REQUEST_URI} !framework # exclude the silverstripe framework which is by the cms
RewriteRule ^(.+)(\.(?:jpe?g|gif|png))$ squeezr/cache/$1-%1$2 [NC,E=BREAKPOINT:%1,L]
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Please make sure that you set this path ^^^ to the squeezr root directory that is also specified
# for the SQUEEZR_ROOT constant in the common engine configuration (SQUEEZR_ROOT/conf/common.php). If you
# apply the default setup for squeezr (i.e. put everything into a directory named "squeezr" under your
# website's document root), then you shouldn't have to change anything.
#############################################################################################################
# REDIRECT ANY DIRECT CSS REQUEST TO A CACHED VERSION
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{ENV:REDIRECT_BREAKPOINT} !\d+px
RewriteCond %{QUERY_STRING} !^([^&]*&)*squeezr=(0|false|no)
RewriteCond %{HTTP_COOKIE} squeezr.css=(\d+x\d+#\d+(?:\.\d+)?) [NC]
RewriteCond %{REQUEST_URI} !cms # exclude the silverstripe cms
RewriteCond %{REQUEST_URI} !framework # exclude the silverstripe framework which is by the cms
RewriteRule ^(.+)\.css$ squeezr/cache/$1-%1.css [NC,E=BREAKPOINT:%1,L]
# ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# See above for hints on ^^^ this path.
#############################################################################################################
### SILVERSTRIPE START ###
RewriteRule ^vendor(/|$) - [F,L,NC]
RewriteRule silverstripe-cache(/|$) - [F,L,NC]
RewriteRule composer\.(json|lock) - [F,L,NC]
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.php$
RewriteRule .* framework/main.php?url=%1 [QSA]
RewriteCond %{REQUEST_URI} ^(.*)/framework/main.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . %1/install.php? [R,L]
### SILVERSTRIPE END ###
</IfModule>
#############################################################################################################
# Additional stuff for improving your website's delivery performance
#############################################################################################################
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css text/javascript text/json text/x-json text/x-json-stream application/x-javascript application/json application/x-json application/x-json-stream application/.*xml.* multipart/x-json-stream multipart/x-mixed-replace image/svg+xml
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
# Images
ExpiresByType image/gif "access plus 35 days"
ExpiresByType image/png "access plus 35 days"
ExpiresByType image/jpg "access plus 35 days"
ExpiresByType image/jpeg "access plus 35 days"
# Text based files
ExpiresByType text/css "access plus 35 days"
ExpiresByType text/xml "access plus 35 days"
ExpiresByType text/javascript "access plus 35 days"
ExpiresByType application/x-shockwave-flash "access plus 35 days"
# Default expiration
ExpiresDefault "access plus 1 days"
</IfModule>