Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php url中的codeigniter公用目录_Php_.htaccess_Codeigniter_Directory_Rewrite - Fatal编程技术网

Php url中的codeigniter公用目录

Php url中的codeigniter公用目录,php,.htaccess,codeigniter,directory,rewrite,Php,.htaccess,Codeigniter,Directory,Rewrite,例如: - index.php - /system - /application - /controller - test.php (class:test ; function index() ; echo "hi") - /public - style.css 我将浏览器指向它,它将显示“hi” 如果我想要style.css,我必须指出 但我想指出的是,你也可以显示style.css 我尝试将index.php移动到public add prefix../before

例如:

- index.php
- /system
- /application
   - /controller
      - test.php (class:test ; function index() ; echo "hi")
- /public
   - style.css
我将浏览器指向它,它将显示“hi”

如果我想要style.css,我必须指出

但我想指出的是,你也可以显示style.css

我尝试将index.php移动到public add prefix../before系统和应用程序中

我还在根目录中设置了一个htaccess,然后我可以成功地指向style.css

但还有一个问题,我不能再指向我的测试控制器,它显示错误404

我如何保存这两个url

更新:

根目录中的htaccess:

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]
当我访问时可以显示style.css

但是控制器测试不工作,我访问show404not“hi”

如果请求的文件来自公共目录,您可以使用测试

# prevent requests for the public directory from being rewritten
RewriteRule ^public/.+$ - [L]

RewriteCond %{DOCUMENT_ROOT}/public/$0 -f
RewriteRule ^.+$ /public/$0 [L]
必须在Codeigniter规则之前插入此规则,否则文件可能会被重写为
/index.php/…

更新

首先,您必须省去
重写cond-f/-d

test/index
的URL必须是
http://mysite.com/test/index
http://mysite.com/test

如果请求的文件来自公共目录,则可以使用进行测试

# prevent requests for the public directory from being rewritten
RewriteRule ^public/.+$ - [L]

RewriteCond %{DOCUMENT_ROOT}/public/$0 -f
RewriteRule ^.+$ /public/$0 [L]
必须在Codeigniter规则之前插入此规则,否则文件可能会被重写为
/index.php/…

更新

首先,您必须省去
重写cond-f/-d


test/index
的URL必须是
http://mysite.com/test/index
http://mysite.com/test

将其置于/public/中并通过/public/style.css调用是有意义的;有什么问题吗?此外,请发布您的.htaccess。htaccess中的重写规则似乎有问题,请发布您的htaccess以获取更多帮助将其置于/public/中并通过/public/style.css调用它是有意义的;有什么问题吗?另外,请发布你的.htaccess。htaccess中的重写规则似乎有问题,发布你的htaccess以获取更多帮助这可以显示css文件,但我的控制器是404 nt,我更新了question@jkjk在你的问题中显示完整的.htaccess。这可以显示css文件,但我的控制器是404NT,我更新了question@jkjk在问题中显示完整的.htaccess。