.htaccess help please? - Post ID 201203

User 404575 Photo


Registered User
887 posts

May I ask for some constructive help with my .htaccess file please?

I have very little idea of what I'm doing. I took some of this from a file that developed from a plugin, back when I had the site hosted at Wordpress and Hostgator. Now my site was rewritten for plain HTML and is hosted back at my old ISP, on an Apache server. One thing that's been suggested, for example, is setting KeepAlive, but my ISP says they don't allow that. Another thing I'll need to add soon, is a 301 redirect, as our site is changing company names and moving from one domain to another, but I don't know how to do that yet. But if you could please look at this and help me take out anything that's not needed and improve it, I'd sure appreciate it. Or if there's a freeware app that might do this in the future, like a htaccess optimizer, I'd be interested. Thanks!



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
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

FileETag none

## 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 year"
ExpiresByType text/javascript "access 1 year"
ExpiresByType application/pdf "access 1 year"
ExpiresByType text/x-javascript "access 1 year"
ExpiresByType application/x-shockwave-flash "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 year"
</IfModule>
## EXPIRES CACHING ##

<IfModule mod_headers.c>
<FilesMatch "\.(js|css|xml|gz)$">
Header append Vary Accept-Encoding
</FilesMatch>
</IfModule>


<IfModule mod_deflate.c>
<IfModule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
</IfModule>

<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>

<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon
</IfModule>

</IfModule>

<FilesMatch "\.(css|js|htc|CSS|JS|HTC)$">
FileETag None


</FilesMatch>
<FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">
FileETag None
</FilesMatch>
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
FileETag None
</FilesMatch>

Melissa Rhiannon
OS Windows 10
User 187934 Photo


Senior Advisor
20,247 posts
Online Now

This should help.
http://www.javascriptkit.com/howto/htaccess.shtml
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 404575 Photo


Registered User
887 posts

Asking for some feedback here Eric. I don't think that site addresses any of this very well, and I don't know what I'm doing, it's like shooting in the dark.
Melissa Rhiannon
OS Windows 10
User 187934 Photo


Senior Advisor
20,247 posts
Online Now

I'm pretty sure that a lot of that stuff is from Wordpress. I would delete it off your server and keep a copy tucked away on your pc. If you not using Wordpress then your going to need an entirely different htaccess file to do things that you might need. Your not going to know that until the need comes up.:)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 404575 Photo


Registered User
887 posts

Well there are some pretty standard things that I understand we DO need now. For one thing, I believe the htaccess file is unique to Apache servers. So there's a whole list of things at gtmetrix.com that should be optimized in the htaccess file, a lot of which I took from the Wordpress htaccess file optimization plugin results. But some of it was made more for Wordpress, so I need to find out how to tune it now, for a non-Wordpress situation. According to gtmetrix.com, some of it needs work, I just don't know how.
Melissa Rhiannon
OS Windows 10
User 187934 Photo


Senior Advisor
20,247 posts
Online Now

htaccess is not required for your site to work and is only to help enhance it for specific situations that evolve and are to much of a pain to handle with other methods.:) The most common use is to protect directories and files.:cool: After that it's pretty easy to screw your site up if you put the wrong thing in.:( I guess if gtmetrix knows so much I would go and ask on their forum.:P
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.