Welcome Guest, Not a member yet? Register   Sign In
SOLVED: Static HTML and htaccess
#1

[eluser]Dr. Seuss[/eluser]
Add the following to the .htaccess cluster below:

Code:
RewriteRule ^js/([a-z0-9_\.]+)\.js$ /static/js/$1.js [NC,L]


////////////////////////
ORIGINAL POST
////////////////////////


Greetings, all.

I am running CI parallel to a static HTML site, with directory structure like so:

+ CI
+ static
+ user_guide
- .htaccess
- index.php

And I am using the following in my .htaccess file to get the static files.

Code:
RewriteEngine On
RewriteRule ^(application) - [F,L]

DirectoryIndex /static/index.html

RewriteRule ^([a-z0-9_-]+)\.html$ /static/$1.html [L]
RewriteRule ^images/([a-z0-9_-]+)\.gif$ /static/images/$1.gif [L]
RewriteRule ^images/([a-z0-9_-]+)\.jpg$ /static/images/$1.jpg [L]
RewriteRule ^css/([a-z0-9_-]+)\.css$ /static/css/$1.css [L]
RewriteRule ^js/([a-z0-9_-]+)\.js$ /static/js/$1.js [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

I put my "assets" ( images, css, etc.) in the static directory structure(since most of what I am using from my CI views is borrowing from the existing site). Everything appears to be working fine with the exception of one thing...

If I wish to include a JQuery plugin, like so:

Code:
<scrtag src="../../js/jquery.autocomplete.js"></scrtag>

(Had to replace "script" with "scrtag" to avoid having the code sample stripped from this post.)

This file will not be served if I attempt to retrieve it directly from the browser address bar.

If I rename the file from "jquery.autocomplete.js" to "autocomplete.js", then this file CAN be retrieved via a request from the browser address bar, but apparently will not load and function correctly within my javascript (the javascript stops executing at precisely the point where the autocomplete() function is called:

Code:
$("#fld").autocomplete("ajax/val", {
    width: 260,
    selectFirst: false
});

I have tried variations on the RewriteRule rule that applies to the /js directory and nothing seems to work--but I am always groping in the dark in .htaccess. Can anyone help?

This is the last thing that I tried and it does not work:

Code:
RewriteRule ^js/jquery\.([a-z0-9_-]+)\.js$ /static/js/jquery.$1.js [L]

Thanks for any assistance.




Theme © iAndrew 2016 - Forum software by © MyBB