I have read about 10 different articles explaining how to write an .htaccess file. I've followed their explanations and put the .htaccess.txt file in the root directory. But still it won't redirect my site from non-www to www.
Here's my .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mecoder.co.il$ [NC]
RewriteRule ^(.*)$ http://www.mecoder.co.il/$1 [L,R=301]
<FilesMatch "\.(jpg|png)$">
Header set Cache-Control "public, max-age=321408000"
</FilesMatch>
<ifModule mod_headers.c>
ExpiresActive On
ExpiresDefault A86400
<FilesMatch "\.(ico|gif|jpg|jpeg\png|flv|pdf|swf|mov|mp3|wmv|ppt)$">
ExpiresDefault A1814400
Header append Cache-Control "public"
</FilesMatch>
<FilesMatch "\.(xml|txt|html)$">
ExpiresDefault A259200
Header append Cache-Control "proxy-revalidate"
</FilesMatch>
<FilesMatch "\.(js|css)$>
ExpiresDefault A10800
Header append Cache-Control "proxy-revalidate"
</FilesMatch>
<FilesMatch "\.(php|cgi|pl)$">
ExpiresDefault A0
Header set Cache-Control "no-store, no-cache, must revalidate, max-age=0"
Header set Pragma "no-cache"
</FilesMatch>
</IfModule>
<ifModule mod_deflate.c>
<FilesMatch "\.(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$">
Header unset ETag
FileETag None
</FilesMatch>
And here is my site
First, it's not .htaccess.txt but .htaccess (without .txt).
If that doesn't work, you must check if overriding with .htaccess file is enabled in your server configuration. To do that, you should add AllowOverride All to your vhost or apache configuration.
Related
I have the site on yii2. I am using pretty URL.
And now I have the following settings for compressing:
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
# Make proxies work as they should.
<IfModule mod_headers.c>
Header append Vary User-Agent
</IfModule>
</IfModule>
How can I enable compressing for url foo1/bar1 and foo2/bar2?
this is my htaccess cache-control policy:
<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico)$"> Header set Cache-Control "max-age=31536000" </FilesMatch>
<FilesMatch "\.(js|css|pdf|swf)$"> Header set Cache-Control "max-age=31536000" </FilesMatch>
<FilesMatch "\.(html|htm|txt)$"> Header set Cache-Control "max-age=600" </FilesMatch>
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$"> Header unset Cache-Control </FilesMatch>
<FilesMatch "\.(eot|otf|ttf|woff|woff2|svg)$"> Header set Cache-Control "max-age=31536000" </FilesMatch>
Now, for webp images is it possible to set a cache-control directive?
Thanks a lot
I have seen examples Apache htaccess file code where compression is before cache and visa versa. Which is correct? I use redbot.org quite a bit and it seems compressing after cache produces fewer issues.
You may compress with gzip compression in this way:
<ifModule mod_deflate.c>
<filesMatch ".(css|js|x?html?|php)$">
SetOutputFilter DEFLATE
</filesMatch>
</ifModule>
To cache files, you could do this:
<ifModule mod_headers.c>
<filesMatch ".(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
<filesMatch ".(css)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
<filesMatch ".(js)$">
Header set Cache-Control "max-age=216000, private"
</filesMatch>
<filesMatch ".(x?html?|php)$">
Header set Cache-Control "max-age=600, private, must-revalidate"
</filesMatch>
</ifModule>
To more informations, visit this page:
http://samaxes.com/2009/01/more-on-compressing-and-caching-your-site-with-htaccess/
present link http://www.easydownlink.com/profile.php?uid=105
i like to show this is as http://www.easydownlink.com/johny12 please give code for it
dudes this is my complete code in htaccess file. i confused where to add mod rewrite for friendly urls. please help me. please give ur valuble suggestions.
DirectoryIndex index.html index.php
Options -Indexes
<IfModule mod_headers.c>
# 1 YEAR
<FilesMatch "\.(ico|pdf|flv)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>
# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 2 DAYS
<FilesMatch "\.(xml|txt|css|js)$">
Header set Cache-Control "max-age=172800, proxy-revalidate"
</FilesMatch>
# 1 MIN
#<FilesMatch "\.(html|htm|php)$">
#Header set Cache-Control "max-age=60, private, proxy-revalidate"
#</FilesMatch>
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 3 days"
ExpiresByType image/jpeg "access plus 3 days"
ExpiresByType image/gif "access plus 3 days"
ExpiresByType image/png "access plus 3 days"
</IfModule>
I have a file called xxx.php and in htaccess i have
<ifModule mod_deflate.c>
<filesMatch "\.(js|css|html|php)$">
SetOutputFilter DEFLATE
</filesMatch>
</ifModule>
how can i disable xxx.php file being cached?
Use a negative lookahead to exclude xxx.php:
<FilesMatch "^(?!xxx\.php$).*\.(js|css|html|php)$">
SetOutputFilter DEFLATE
</FilesMatch>