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
http://hawkiqshare.netne.net/share.html

bef0ea1f4dca89ccf462e73e661bc09f

Recommended Answers

All 3 Replies

Member Avatar for diafol

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 http://ww.yoursite.com/js/script.js 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.