I have some problems with rewriting URL-s
my .htacces file:
RewriteEngine On
RewriteBase /bsc/
RewriteRule ^(.+/?)$ index.php?url=$1 [NC,QSA,L]
my file and folder structure:
bsc/
---|.htaccess
---|index.php
---|css/
-------|style.css
---|images/
----------|logo.png
----------|image1.jpg
----------|image2.jpg
---|controller/
--------------|bootstrap.php
...
When I have next link
localhost/bsc/page.html
Than my css work or I can get to work. But when I have next links:
localhost/bsc/page/subpage.html
localhost/bsc/page/subpage/subsubpage.html
localhost/bsc/page/subpage/subsubpage/subsubsubpage.html
I can't get css to work, css is redirected to
localhost/bsc/page/css/style.css
localhost/bsc/page/subpage/css/style.css
localhost/bsc/page/subpage/subsubpage/css/style.css
Second part of problem is that my links don't have same extensions or any extension. Next situations are possible:
localhost/bsc/page/subpage
localhost/bsc/page/subpage/
localhost/bsc/page/subpage.php
localhost/bsc/page/subpage.html
localhost/bsc/page/subpage/subsubpage
localhost/bsc/page/subpage/subsubpage/
localhost/bsc/page/subpage/subsubpage.php
localhost/bsc/page/subpage/subsubpage.html
...
Now defined rewrite rule is working for different links but how to add excluded rule for css and images?
I get next .htaccess that work for css for all my conditions:
RewriteEngine On
RewriteBase /bsc/
RewriteCond %{REQUEST_FILENAME} !\.css
RewriteRule ^(.+/?)$ index.php?url=$1 [NC,QSA,L]
After reading comments and some time I get next .htaccess file with not so bad results:
RewriteEngine On
RewriteBase /bsc/
RewriteRule ^(.+/?)?(/|\.htm|\.php|\.html|/[^.]*)$ index.php?url=$1 [NC,QSA,L]
and my link tag is:
<link rel="stylesheet" type="text/css" href="/bsc/css/style.css" />
Now it is only one condition in URL when I can't get correct URL request. Next URL don't receive last parameter:
localhost/bsc/page/subpage
localhost/bsc/page/subpage/subsubpage
I don't receive subpage or subsubpage, other conditions are working. In this situation apache and .htaccess tray to find file or folders ....
Is it possible to add missing condition or is it possible to make some simplest rewrite rule or more rules