tags:

views:

14

answers:

1

I am just trying to understand how .htaccess work and what is right way of dealing with it and I have one problem. Here is part of my .htaccess file:

RewriteEngine on
RewriteRule ^(.*)/css/(.*)$ /css/$2
RewriteRule ^(.*)/img/(.*)$ /img/$2
RewriteRule ^(.*)/js/(.*)$ /js/$2

Everything is looks fine and have worked ok, till I'll try to use TinyMCE that I have copied to js directory. It contain a lot of different subfolders, including img subfolders, and because of my rule RewriteRule ^(.*)/img/(.*)$ /img/$2 it doesn't work properly. I know that I can just rename folders in TinyMCE, but I think that I am not dealing with .htaccess in right way. Help me please.

+2  A: 

Instead of matching any character in your rule, you can match one folder (allow every character except for /). That'll ensure that deep nested folders (e.g. modules/tinymce/js/) do not conflict with en/js/.

RewriteEngine on
RewriteRule ^([^/]*)/css/(.*)$ /css/$2
RewriteRule ^([^/]*)/img/(.*)$ /img/$2
RewriteRule ^([^/]*)/js/(.*)$ /js/$2
Lekensteyn
It is exactly, that I need! Thank you!
andrii