homepage Welcome to WebmasterWorld Guest from 54.145.183.169
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Running linux server on shared host and need some help with htaccess
pityocamptes

5+ Year Member



 
Msg#: 4652000 posted 3:50 pm on Mar 7, 2014 (gmt 0)

This pertains to vbulletin forum software. I found this htaccess code that is supposed to speed up a site, but after loading the code to my htaccess file, members several hours later said that the site came to a screeching halt. Could someone perhaps look at the code and explain why it happened, and how I might be able to fix it, or offer a different solution? I'm not very knowledgable when it comes to htaccess and any help appreciated. Thanks.

As a side its a shared hosting server on Godaddy... I know, probably a mistake, and will look for a new host once my subscription runs out in a few months...



Header set Connection keep-alive

# Version 2.6
RewriteEngine on

#Deny attempts to view the Htaccess file.
<Files .htaccess>
Order allow,deny
Deny from all
</Files>
# BEGIN Browser Caching/Headers
<IfModule mod_mime.c>
AddType text/css .css
AddType text/richtext .rtf .rtx
AddType image/svg+xml .svg .svgz
AddType text/plain .txt
AddType text/xsd .xsd
AddType text/xsl .xsl
AddType video/asf .asf .asx .wax .wmv .wmx
AddType video/avi .avi
AddType image/bmp .bmp
AddType application/java .class
AddType video/divx .divx
AddType application/msword .doc .docx
AddType application/x-msdownload .exe
AddType image/gif .gif
AddType application/x-gzip .gz .gzip
AddType image/x-icon .ico
AddType image/jpeg .jpg .jpeg .jpe
AddType application/vnd.ms-access .mdb
AddType audio/midi .mid .midi
AddType video/quicktime .mov .qt
AddType audio/mpeg .mp3 .m4a
AddType video/mp4 .mp4 .m4v
AddType video/mpeg .mpeg .mpg .mpe
AddType application/vnd.ms-project .mpp
AddType application/vnd.oasis.opendocument.database .odb
AddType application/vnd.oasis.opendocument.chart .odc
AddType application/vnd.oasis.opendocument.formula .odf
AddType application/vnd.oasis.opendocument.graphics .odg
AddType application/vnd.oasis.opendocument.presentation .odp
AddType application/vnd.oasis.opendocument.spreadsheet .ods
AddType application/vnd.oasis.opendocument.text .odt
AddType audio/ogg .ogg
AddType application/pdf .pdf
AddType image/png .png
AddType application/vnd.ms-powerpoint .pot .pps .ppt .pptx
AddType audio/x-realaudio .ra .ram
AddType application/x-shockwave-flash .swf
AddType application/x-tar .tar
AddType image/tiff .tif .tiff
AddType audio/wav .wav
AddType audio/wma .wma
AddType application/vnd.ms-write .wri
AddType application/vnd.ms-excel .xla .xls .xlsx .xlt .xlw
AddType application/zip .zip
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css A2628000
ExpiresByType text/richtext A3600
ExpiresByType image/svg+xml A3600
ExpiresByType text/plain A3600
ExpiresByType text/xsd A3600
ExpiresByType text/xsl A3600
ExpiresByType video/asf A2628000
ExpiresByType video/avi A2628000
ExpiresByType image/bmp A2628000
ExpiresByType application/java A2628000
ExpiresByType video/divx A2628000
ExpiresByType application/msword A2628000
ExpiresByType application/x-msdownload A2628000
ExpiresByType image/gif A2628000
ExpiresByType application/x-gzip A2628000
ExpiresByType image/x-icon A2628000
ExpiresByType image/jpeg A2628000
ExpiresByType application/vnd.ms-access A2628000
ExpiresByType audio/midi A2628000
ExpiresByType video/quicktime A2628000
ExpiresByType audio/mpeg A2628000
ExpiresByType video/mp4 A2628000
ExpiresByType video/mpeg A2628000
ExpiresByType application/vnd.ms-project A2628000
ExpiresByType application/vnd.oasis.opendocument.database A2628000
ExpiresByType application/vnd.oasis.opendocument.chart A2628000
ExpiresByType application/vnd.oasis.opendocument.formula A2628000
ExpiresByType application/vnd.oasis.opendocument.graphics A2628000
ExpiresByType application/vnd.oasis.opendocument.presentation A2628000
ExpiresByType application/vnd.oasis.opendocument.spreadsheet A2628000
ExpiresByType application/vnd.oasis.opendocument.text A2628000
ExpiresByType audio/ogg A2628000
ExpiresByType application/pdf A2628000
ExpiresByType image/png A2628000
ExpiresByType application/vnd.ms-powerpoint A2628000
ExpiresByType audio/x-realaudio A2628000
ExpiresByType application/x-shockwave-flash A2628000
ExpiresByType application/x-tar A2628000
ExpiresByType image/tiff A2628000
ExpiresByType audio/wav A2628000
ExpiresByType audio/wma A2628000
ExpiresByType application/vnd.ms-write A2628000
ExpiresByType application/vnd.ms-excel A2628000
ExpiresByType application/zip A2628000
</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/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon
</IfModule>
</IfModule>
<FilesMatch "\.(css|CSS|)$">
<IfModule mod_headers.c>
Header set Pragma "public"
Header append Cache-Control "public, must-revalidate, proxy-revalidate"
</IfModule>
FileETag MTime Size
<IfModule mod_headers.c>
Header set X-Powered-By "Step by Step guide to speed up your VB4 (forum only)"
</IfModule>
</FilesMatch>
<FilesMatch "\.(rtf|rtx|svg|svgz|txt|xsd|xsl|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|)$">
<IfModule mod_headers.c>
Header set Pragma "public"
Header append Cache-Control "public, must-revalidate, proxy-revalidate"
</IfModule>
FileETag MTime Size
<IfModule mod_headers.c>
Header set X-Powered-By "Step by Step guide to speed up your VB4 (forum only)"
</IfModule>
</FilesMatch>
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|
mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|
pdf|png|pot|pps|ppt|pptx|ra|ram|swf|tar|tif|tiff|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|
ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|
MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|
PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SWF|TAR|TIF|TIFF|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
<IfModule mod_headers.c>
Header set Pragma "public"
Header append Cache-Control "public, must-revalidate, proxy-revalidate"
</IfModule>
FileETag MTime Size
<IfModule mod_headers.c>
Header set X-Powered-By "Step by Step guide to speed up your VB4 (forum only)"
</IfModule>
</FilesMatch>
# End Browser Caching/Headers

 

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4652000 posted 7:22 pm on Mar 7, 2014 (gmt 0)

i don't see anything that would slow you down but i also don't see any mod_rewrite directives.

i would suggest using this:
ExpiresDefault A2628000

and then override the default as required:
ExpiresByType text/richtext A3600
ExpiresByType image/svg+xml A3600
ExpiresByType text/plain A3600
etc...


you can limit the scope of the ExpiresDefault directive if you wish by enclosing it in a <Files> or <FilesMatch> container.

pityocamptes

5+ Year Member



 
Msg#: 4652000 posted 9:13 pm on Mar 7, 2014 (gmt 0)

Not sure I follow you. Htaccess stuff, is something I am not really familiar with. Actually borrowed the code from online. Could you walk me through it a little more in detail. I would greatly appreciate it. Thank you.

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4652000 posted 10:42 pm on Mar 7, 2014 (gmt 0)

<FilesMatch "\.(css|CSS|)$">

What is the third option (nothing after the .) intended to do?

What are all those <IfModule envelopes for? This is a specific site in a specific location, so you've either got the module or you haven't. Find out, and code accordingly.

Anyway, you've got way too many things in there for a simple analysis. What you have to do is delete the whole thing and then add pieces bit by bit and see what triggers the misbehavior.

Does your site really use all those different filetypes? I count over 40 in the "Expires" section. Get rid of the ones you don't use and put the rest in alphabetical or thematic order so you can find them later.

Similarly, do you even need all those AddType directives? Seems like most of them are just redeclaring the default.

Leave blank lines between each group of directives. In htaccess, unlike robots.txt, a blank line has no semantic meaning. It's purely to preserve your own sanity.

Blocking direct access to htaccess does no harm. But surely even godaddy would say this by default in the config file? In fact it probably says
<FilesMatch "^\.ht">
to cover htpasswd as well. Maybe even simply
FilesMatch ^\.
for anything with a leading dot (same as system files on your home computer).

If something is already in the config file, you don't need to repeat it in htaccess. Almost everything --except mod_rewrite-- is inherited by default.

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4652000 posted 10:44 pm on Mar 7, 2014 (gmt 0)

i gave you some suggestions that would make it easier to maintain your configuration.
don't worry about that until you fix your problem.

there's nothing in my answer that addresses the server speed problem.
the only thing in your .htaccess that uses any processing power is the compression (DEFLATE)

try turning that off.

there's other stuff you're not showing - like the internal rewrite to the vb script, for example.

pityocamptes

5+ Year Member



 
Msg#: 4652000 posted 1:21 am on Mar 8, 2014 (gmt 0)

Ok, if you would be so kind, my site is sucking on webpagtest. Site is <snip>

Here is what I have for my htaccess currently - after removing all the stuff I found that I posted above. Any help is GREATLY appreciated to see if I can speed things up, or reduce the load time. I have shrunk all pics, templates, etc. I'm not very good at this stuff from a server side so any recommendations are appreciated. Thanks again!

# Use PHP 5.3
AddType application/x-httpd-php53 .php .html .htm


<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>


RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

RewriteCond %{SERVER_PORT} !443
RewriteRule (.*) https://www.example.com [R=301,L]

# If you are having problem with "None Could Be Negotiated" errors in Apache, uncomment this to turn off MultiViews
Options -MultiViews

RewriteCond %{REQUEST_URI} !(XXXXX/|XXXXXX/|XXXXXX/|cron|mobiquo|forumrunner|api\.php)
RewriteRule ^((archive/)?(.*\.php(/.*)?))$ dbseo.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/(XXXXXX|XXXXXXX|XXXXX|clientscript|cpstyles|images)/
RewriteRule ^(.+)$ dbseo.php [L,QSA]

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType application/javascript A604800
ExpiresByType application/x-javascript A604800
ExpiresByType text/javascript A604800
ExpiresByType text/css A604800
ExpiresByType image/gif A604800
ExpiresByType image/x-icon A604800
ExpiresByType image/icon A604800
ExpiresByType image/jpg A604800
ExpiresByType image/jpeg A604800
ExpiresByType image/png A604800
ExpiresByType text/html A604800
</IfModule>

# BLOCK COUNTRY BY IP RANGE

<Limit GET POST HEAD>
order allow,deny
# Block from USA
#
deny from 192.187.109.66
...and a couple hundred more... for other countries...
allow from all
</Limit>

[edited by: incrediBILL at 1:47 am (utc) on Mar 8, 2014]

[edited by: phranque at 3:40 am (utc) on Mar 8, 2014]
[edit reason] Please use EXAMPLE.COM for all domain names [/edit]

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4652000 posted 1:56 am on Mar 8, 2014 (gmt 0)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/(XXXXXX|XXXXXXX|XXXXX|clientscript|cpstyles|images)/
RewriteRule ^(.+)$ dbseo.php [L,QSA]

Ouch. That's a wallop on your server right there. If nothing else, the third condition should go first: If the request is for anything in these directories, stop right there.

I smell a CMS. Well, you did say vbulletin at the beginning.

:: detour to check something ::

Oh, OK, %{REQUEST_FILENAME} doesn't really mean "filename" (as in <Files> envelopes) it means "full physical path and/or URLpath depending on various stuff 2C2E".

RewriteCond %{REQUEST_URI} !(XXXXX/|XXXXXX/|XXXXXX/|cron|mobiquo|forumrunner|api\.php)
RewriteRule ^((archive/)?(.*\.php(/.*)?))$ dbseo.php [L,QSA]

This can almost certainly be cleaned up. Do all those permutations actually occur? What's with the potential extra stuff after ".php"? What on earth do your URLs look like? :)

I hope your dbseo.php page -- which should be /dbseo.php with leading slash -- returns 404 responses when appropriate. Otherwise you're looking at Duplicate Content up the wazoo.

pityocamptes

5+ Year Member



 
Msg#: 4652000 posted 2:10 am on Mar 8, 2014 (gmt 0)

Ok,I admit you lost me... the dbseo stuff was entered by the dragonbyte seo maker...

I am running SSL if that makes a difference... I also have a rewrite for seo friendly url's...

I ran the dbseo.php and I get a blank page...

I don't really know what to do? Help....

pityocamptes

5+ Year Member



 
Msg#: 4652000 posted 2:11 am on Mar 8, 2014 (gmt 0)

If you would be so kind to let me know what you think, my web site is:

<snip>

[edited by: phranque at 3:40 am (utc) on Mar 8, 2014]
[edit reason] Please Use example.com [webmasterworld.com] [/edit]

tangor

WebmasterWorld Senior Member tangor us a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



 
Msg#: 4652000 posted 2:30 am on Mar 8, 2014 (gmt 0)

Try it clean... there's a lot of hooey in that list above. Fork out 99% and try again. Seriously. Appears you inserted this to speed up your site and got the opposite result. Restore your original in get back in biz. Seems like a no brainer for me.

pityocamptes

5+ Year Member



 
Msg#: 4652000 posted 2:45 am on Mar 8, 2014 (gmt 0)

The rewrites were actually done for me by another person and the reason was so that no matter if you put in http / https / www/ or just url it would all redirect to https...

As for the second part:

RewriteCond %{REQUEST_URI} !(XXXXX/|XXXXXX/|XXXXXX/|cron|mobiquo|forumrunner|api\.php)
RewriteRule ^((archive/)?(.*\.php(/.*)?))$ dbseo.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/(XXXXXX|XXXXXXX|XXXXX|clientscript|cpstyles|images)/
RewriteRule ^(.+)$ dbseo.php [L,QSA]

I honestly do not know what that does. I know I was having major issues until the owner of dragonbyte (SEO) put that in for the frienly urls and seo to work...

pityocamptes

5+ Year Member



 
Msg#: 4652000 posted 2:47 am on Mar 8, 2014 (gmt 0)

This part was done to speed up site, again from another poster on vbulletin:

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType application/javascript A604800
ExpiresByType application/x-javascript A604800
ExpiresByType text/javascript A604800
ExpiresByType text/css A604800
ExpiresByType image/gif A604800
ExpiresByType image/x-icon A604800
ExpiresByType image/icon A604800
ExpiresByType image/jpg A604800
ExpiresByType image/jpeg A604800
ExpiresByType image/png A604800
ExpiresByType text/html A604800
</IfModule>


To be honest guys, I can program, but was never good at server side stuff, your patience and help appreciated. Thanks.

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4652000 posted 3:14 am on Mar 8, 2014 (gmt 0)

But those are all exactly the same, A604800
:: business with calculator ::
one week. Why not just set an expiration default, as suggested earlier in this thread, and then set a different value for html and php? If it's a forum, the expiration time for pages should be fairly short, unless the URL changes with each new post.

You may not even need to set an expiration cutoff for non-page files; browsers can often be trusted to handle this on their own. When I change MAMP from one site to another* I get the new domain's content with the old domain's css. (Same filename and path.) No biggie on the two primary sites-- it's just different shades of blue-- but pretty catastrophic when anything else is involved.


* On account of I've never had the nerve to delve into the vhosts file to enable multiple sites concurrently.

pityocamptes

5+ Year Member



 
Msg#: 4652000 posted 3:22 am on Mar 8, 2014 (gmt 0)

Lucy24, could you give me an example or help me with the htaccess code I posted? Ok, looked again, I think I know what you mean. Can you give suggesttions on expiration times for the values I listed?

Also, can you suggest adding anything to my htaccess that might actually speed things up?

Webpagetest shows:

Fully loaded time: 13.606s Requests: 109 Bytes in: 630 KB

With "F" on pretty much everything...

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4652000 posted 9:38 am on Mar 8, 2014 (gmt 0)

If those numbers mean it takes thirteen and a half seconds for a page to finish loading, I can see why you're looking for page-speed suggestions. But I'd look first at the number and size of requests.

Requests: 109

First reaction: What the bleep bleep? A single page comes with 108 supporting files? There's got to be stuff you can trim there. Are all 109 from your own site? It's even worse if a page requires multiple items from other places. Especially visible items. It's no skin off anyone's nose if the analytics code doesn't finish loading until several seconds after the user has started reading.

:: counting on fingers ::

630k / 109 requests means that each file averages 5-6k. Presumably somewhat more for the main page, also more if you have any banner-type pictures. On a forum there will also be things like avatars and/or signatures. But not 109 of them on a single page, surely.

That leaves you with an appalling lot of very small files. You don't happen to have a ###load of weeny little icon-type graphics, do you? Especially ones that have to be pulled in from other sites. Or is yours one of those sites that ends up with eighteen* stylesheets?


* For a long time, this was the highest number of external stylesheets I'd ever counted, anywhere. Recently I found one with more-- many more-- in fact, so many more that I've blocked the number. Buncha js in there too.

pityocamptes

5+ Year Member



 
Msg#: 4652000 posted 7:53 pm on Mar 9, 2014 (gmt 0)

Thanks. How can I find out what the requests are that are being called, so that I can go from there? Thanks.

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4652000 posted 8:56 pm on Mar 9, 2014 (gmt 0)

Well, you should know from the page source alone.

Browser starts by requesting pagename.html. Or pagename.php or pagename.jsp or pagename-go-back-in-the-server-and-put-some-clothes on. Work with me here. Once it's got that, it combs the page for required supporting files-- images, external stylesheets, external scripts, maybe some other stuff I can't think of at the moment.

Pull up a random page. If it's php-generated-- as I assume a forum would be-- don't look at your physical source code. Get the actual page that's sent out to browsers. Open up the html and search globally for the two elements

:: detour to check a random page ::

<link
and
src

On the page that cited 109 requests, you should find 108 of them.

The other approach is to grab the latest day's logs. Home in on any human html request and then scoop up everything from the same IP. Again, there should be a set of 109 including the html. If there's significantly less, it means a lot of those 109 requests are going out to other sites. This is seriously bad news from a page-speed standpoint, but may be out of your power to change. (Well, not always. Forums make individual choices about things like allowing hotlinking in posts, whether to allow avatar and/or signature images, and if so, where to host them.)

Some forums have a bunch of teeny little icons along the bottom of each post, and some of those lead to requests from other sites. On a sluggish day you can see it with your eyeballs as a page slowly loads up. When I saw the number "109" my first thought was "css sprites".

:: memo to self: Do Something about the 24 separate teeny gifs that currently make up the "Know Your Lion" page ::

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved