【问题标题】:Allow access to folder which is inside the \application\ folder in Codeigniter允许访问 Codeigniter 中 \application\ 文件夹内的文件夹
【发布时间】:2013-07-15 19:08:59
【问题描述】:

我想知道,如何让公众访问放置在名为“Sample”的文件夹中的文件,该文件夹位于 /applications/views/ 中。

我尝试使用 .htaccess 文件来做到这一点。

这是我现在使用的 .htaccess 文件。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /0.9.1

#Removes access to the system folder by users.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

#Checks to see if the user is attempting to access a valid file,
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#Enable access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|application\views\Sample\/public)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

任何帮助将不胜感激。谢谢。

【问题讨论】:

  • 您的公共文件应放在./assets 而不是./application 不应从该文件夹向浏览器提供任何内容。

标签: php .htaccess codeigniter mod-rewrite


【解决方案1】:

您是否将图像、css、js 等放在应用程序文件夹中?如果您就停在那里。应用程序和系统文件夹不允许直接脚本访问,应该保持这种方式。任何你想公开的东西都应该放在一个名为 public 的文件夹中,并将它放在你的应用程序和系统目录旁边的根目录中。

【讨论】:

  • 嗯……我有点绕过去了。但是,我现在卡在别的事情上了。我在这里发布了另一个相关问题:stackoverflow.com/questions/17697996/… 如果您能帮助我,我将不胜感激。我喜欢你在回复中使用粗体字的方式。 +1 :)
  • 谢谢,加粗是一门艺术
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-11-12
  • 1970-01-01
  • 2021-08-13
  • 1970-01-01
  • 1970-01-01
  • 2015-06-13
  • 2017-08-10
相关资源
最近更新 更多