.htaccess break all css and js, although I set the absolute path

Here is my .htaccess file

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !=cms

RewriteRule ^([^/]*)/search/([^/]+)$  index.php?lang=$1&id=search&searchword=$2 [L]
RewriteRule ^([^/]*)/([^/]*)$  index.php?lang=$1&id=$2 [L]

This does not work as I expect.

My files .css, .jshave an absolute path, for example http://bs.am/finance/css/style.css(all of my files in the folder finance)

The first rule breaks all css and js files, but if I replace the rewriteRules places, it works fine.

Can someone explain this behavior?

I also tried RewriteCond %{REQUEST_FILENAME} !^(.+)\.css$but did not help.

Thank you so much

+3
source share
2 answers

, , .htaccess /finance/. , , RewriteRule .

, , , , ( ). , , RewriteCond, . :

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 =cms
RewriteRule ^([^/]*)/search/([^/]+)$  index.php?lang=$1&id=search&searchword=$2 [L]

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !=cms
RewriteRule ^([^/]*)/([^/]*)$  index.php?lang=$1&id=$2 [L]

, , , , , . , , .

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond $1 !=cms
RewriteRule ^([^/]*) - [S=2]

RewriteRule ^([^/]*)/search/([^/]+)$  index.php?lang=$1&id=search&searchword=$2 [L]
RewriteRule ^([^/]*)/([^/]*)$  index.php?lang=$1&id=$2 [L]

, - , ( S=2). , . Gumbo , L S=2, , . , .

+2

A RewriteCond RewriteRule. , RewriteCond RewriteRule, , .

, RewriteRule, RewriteCond :

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !=cms
RewriteRule ^([^/]*)/search/([^/]+)$  index.php?lang=$1&id=search&searchword=$2 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !=cms
RewriteRule ^([^/]*)/([^/]*)$  index.php?lang=$1&id=$2 [L]

, , :

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

, .

+1

Source: https://habr.com/ru/post/1769086/


All Articles