Mod_rewrite with Trailing Slash breaks CSS / IMG / SCRIPTS paths

I am trying to make mod_rewrite the first line of a subdirectory from url to create similar functionality as the "jsfiddle.net saved url in class / db. Script works fine and rewrites.

eg. url

http://jsfiddle.net/RyEue/

This works fine (loads all css, scripts, etc.):

http://www.domain.com/787HHJ2

This is what I used in the past that does the trick.

The problem is that when the URL ends with the last slash, script, css and other lost paths.

http://www.domain.com/787HHJ2/

rewrite script:

DirectoryIndex index.php index.html
Options +FollowSymlinks
RewriteEngine On # Turn on the rewriting engine
#RewriteBase   /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} !.
RewriteRule ^.+/?$ index.php [QSA,L]

Not sure if this is related to Rewritebase, I tried several ways.

PS. I tried setting absolute paths (e.g. src = "/img/theimage.jpg") with no luck.

+5
2

1. , css/images/js .. ( ): /styles/main.css

2. ruls :

# do not touch files with .css/.js/.jpg etc extensions
RewriteRule \.(css|js|jpg|png|gif)$ - [L]

# do not touch any resources in images/css/js folders
RewriteRule ^(images|css|js)/ - [L]

3. ( /, , ).

+5

RewriteRule ^.+\/?$ index.php [QSA,L]
0

All Articles