I have problem in my site and accrues only when using htaccess, I have many css and js files stored in my site
when import them on localhost by using relative path

<script src="js/jquery.min.js"></script>

when using htaccess the js or css cannot be loaded and firefox show me message
"The connection was reset
The connection to the server was reset while the page was loading.
"

I've tried many browsers and same problem still
but when using CDN for files it loaded succefully like :

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

how to solve this problem .
live example

bef0ea1f4dca89ccf462e73e661bc09f

Dani AI

Generated

Brief summary and likely cause:
The symptoms (static CSS/JS failing only when the site .htaccess is active and the browser showing a connection reset) point to the server dropping or mishandling requests for local assets. The suggestions from and are on the right track — static assets must be exempted from rewrite processing — but the exemption can be too narrow (it sometimes matches only the bare directory name and not deeper file paths). Other common causes that produce a connection reset include host-level WAF/mod_security rules, an Apache/PHP process crash, or file-permission/access problems.

Practical diagnostic checklist (in order):

  • Confirm the asset request itself: run a verbose fetch to see TCP/HTTP behavior.
    curl -v 'http://example.com/js/jquery.min.js'
  • Temporarily disable .htaccess (rename it) and re-request the same asset. If the file serves, the problem is in the file. If not, check permissions/ownership (typical file perms 644, dirs 755) and host restrictions.
  • Inspect server logs immediately after a failing request (Apache error log, mod_security or PHP-FPM logs). Example:
    tail -n 200 /var/log/apache2/error.log

    Look for segfaults, mod_security hits, or repeated rewrite failures.

Targeted fixes to try

  • Prefer an early exemption that matches actual static file requests (files by extension), placed before any “catch-all” rewrite rules. For example, exempt requests that end in common static extensions so they never reach the main rewrite logic:
    # place near top of rewrite section
    RewriteRule \.(css|js|png|jpe?g|gif|svg|ico|woff2?|ttf)$ - [L]
  • If the above still fails, reintroduce .htaccess sections one block at a time (comment/uncomment) to isolate which rule triggers the reset.
  • If logs show mod_security or a firewall dropping connections, escalate to the host and provide timestamps and request lines for their review.

Notes and cautions:
If renaming .htaccess fixes things, re-enable rules incrementally. If nothing in .htaccess appears responsible, the host’s security layer or a server process crash is the likely culprit — server logs and host support will be required.

Recommended Answers

All 3 Replies

Member Avatar for Member #120589

Set exception to rule before the rewrite line

RewriteRule ^(js|css|images|fonts)($|/) - [L]

Agree with @diafol, but personally I'd add this too:

// Turn rewrite engine on

RewriteRule ^(js|css|images|fonts)($|/) - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

// Rewrite rule goes here

Line 2 tells the rewrite rule to search for any files that actually exist, so if you had SITE_ROOT/js/script.jsand looked for it would show that JS file. If it can't match the URL with a file on your server, it proceeds to follow whatever rules you've got after it.

Line 3 does the same with directories: if the directory exists, it'll show it, if not, it'll follow your rewrite rules.

Hope that sort of makes sense, but it should solve your problem. One thing is for sure though, .htaccess is the most frustrating thing to work with. Ever.

I don't know what is wrong still same problem for me
still the same error "net::ERR_CONNECTION_RESET"

2205427f27bf76b3ce5e8607842c1cfe

here is my .htaccess file contents

Options All -Indexes
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^(js|css|images|fonts)($|/) - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^index.html$ index.php
RewriteRule ^share.html$ sharecenter.php
RewriteRule ^upload.html$ upload.php
RewriteRule ^settings.html$ settings.php
RewriteRule ^favorite.html$ favorite.php
RewriteRule ^pending.html$ pending.php
RewriteRule ^messages.html$ pm.php
RewriteRule ^u-(.*).html$ profile.php?user=$1
ErrorDocument 404 /404.htm

<Files .htaccess>
Order Allow,Deny
Deny from all
</Files>

#######################
RewriteCond %{QUERY_STRING} proc/self/environ [OR]
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|%3D) [OR]
RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
#######################
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.