Codeigniter网址中的访问被拒绝错误包含index.php

时间:2018-10-12 10:27:32

标签: php .htaccess codeigniter ubuntu

我遇到的问题可能与ubuntu的.htaccess或php配置有关。我已经尽力寻找解决方案,但感到无助,所以最后我决定在这里发布一个问题。可能是我的问题很愚蠢,还是我在非常正常的配置点上犯了错误,但最终我希望我的问题能帮助我找到您所有的祝福的解决方案。

请支持我找出解决问题的方法。

我的问题是,当我打开url时没有在URL中插入index.php时,它会输出成功,但是一旦我将index.php放在url中时,它只会给出“拒绝访问”的响应。

示例

  

它给我“访问被拒绝”的响应

It gives access denied

  

它工作正常,但是我所有的URL更改花费了更长的时间

It's working fine

MY .htaccess

<IfModule mod_env.c>
    SetEnv CI_ENV development
</IfModule>

<IfModule mod_rewrite.c>

RewriteEngine On
#RewriteBase /CodeIgniter_2.0.3

#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|assets|files|robots\.txt)
RewriteRule ^(.*)$ index.php?$1 [L]

</IfModule>
#Allow access from all domains for webfonts.
<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css|js|jpg|jpeg|png|gif|swf)$">
    Header set Access-Control-Allow-Origin "*"
    Header set Cache-Control "max-age=604800, public"
  </FilesMatch>
</IfModule>

我找不到解决此问题的方法。您的帮助将不胜感激

感谢您访问...

1 个答案:

答案 0 :(得分:0)

尝试将它们放在您的.htaccess文件中
我总是在apache服务器上使用它,并且可以正常工作

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA]