I am creating a rule to display addresses of type :
main.php?cat=MyCategory
main.php?cat=MyCategory&sub=MySubcategory
main.php?cat=MyCategory&sub=MySubcategory&prod=MyProduct
As
MyDomain.com/MyCategory
MyDomain.com/MyCategory/MySubcategory
MyDomain.com/MyCategory/MySubcategory/MyProduct
but there are two problems:
The first problem is that the other links on the displayed page start in the wrong position.
MyDomain.com/MyCategory/MySubcategory/MyProduct/newlink.html
should be referenced to the root, like this
MyDomain.com/newlink.html
Second problem is that from 2nd/3rd URL levels, my references such as javascript, img src and css links are wrong. It looks for these files relative from the up levels url. How do I fix this?
My .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ principal.php?cat=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)$ principal.php?cat=$1&sub=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ principal.php?cat=$1&sub=$2&prod=$3 [L]
Tried with:
RewriteCond %{REQUEST_URI} !^/newlink\.html$
But not working, any ideas?