Reputation: 1075
In example:
- index.php
- /system
- /application
- /controller
- test.php (class:test ; function index() ; echo "hi")
- /public
- style.css
I point the browser to http://mysite.com/ it will show "hi"
If I want style.css, I must point to http://mysite.com/public/style.css
But I want to point http://mysite.com/style.css can show style.css too
I tried move index.php into public add prefix ../ before system and application
Also I setup a htaccess in root directory,then I can successfully point http://mysite.com/style.css for style.css
But there's another problem,I can't point to my test controller anymore,it show error 404
How can I keep both url?
UPDATE:
htaccess in root dir:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^public/.+$ - [L]
RewriteCond %{DOCUMENT_ROOT}/public/$0 -f
RewriteRule ^.+$ /public/$0 [L]
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
when I visit http://mysite.com/style.css can show style.css
but the controller test in not work,I visit http://mysite.com/test/test/index show 404 not "hi"
Upvotes: 1
Views: 2336
Reputation: 74018
You can test with a RewriteCond
if the requested file is from the public directory
# prevent requests for the public directory from being rewritten
RewriteRule ^public/.+$ - [L]
RewriteCond %{DOCUMENT_ROOT}/public/$0 -f
RewriteRule ^.+$ /public/$0 [L]
You must insert this rule before the Codeigniter rule, because otherwise the file could be rewritten to /index.php/...
.
Update:
First, you must leave out the RewriteCond !-f/!-d
.
The URL for test/index
must be http://mysite.com/test/index
or http://mysite.com/test
.
Upvotes: 1