Reputation: 113
I need to access images, css and js files in my pages, but I don't know write the .htaccess file needed.
I'm using CodeIgniter.
The mine folders hierarchy:
/cv |__ cartao_virtual | | | |__ cms | | |__ assets | | | | | | | |__ **css** | | | | |__ **images** | | | | | | | |__ **js** | | | | | |__ controllers | | |__ models | | |__ views | | | |__ site | |__ assets | | | | | |__ css | | | |__ images | | | | | |__ js | | | |__ controllers | |__ models | |__ views | |__ system | |__.htacess |__ site.php (default CodeIgniter index.php) |__ cms.php (default CodeIgniter index.php)
My current .htaccess is:
RewriteCond $1 !^(cms\.php|cms|assets) RewriteRule ^cms$ cms.php [L] RewriteRule ^cms/(.*)$ cms.php/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ site.php/$1 [L]
With it, I just have access to cms and site controllers and your methods, and I want keep so.
I'm imagining something like:
RewriteEngine on RewriteCond $1 !^(cms\.php|cms) RewriteRule ^cms$ cms.php [L] RewriteRule ^cms/(.*)$ cms.php/$1 [L] RewriteCond $1 !^(^cms/assets|site/assets) RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ site.php/$1 [L] RewriteCond $1 !^(site/assets) RewriteRule ^site/assets/(.*)$ cartao_virtual\/site\/assets\/$1 [L] RewriteCond $1 !^(cms/assets) RewriteRule ^cms/assets/(.*)$ cartao_virtual\/cms\/assets\/$1 [L]
Thanks in advanced.
Upvotes: 0
Views: 845
Reputation: 7880
Anywhere you're rewriting (.*)
you'll need the following rewrite conditions to not include real files.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Right now you're inadvertently redirecting all traffic whether a file or directory exists or not with the exception of one rule.
Upvotes: 2