php - codeigniter url 中的访问被拒绝错误具有 index.php

标签 php .htaccess codeigniter ubuntu

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

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

我的问题是,当我在 url 中没有 index.php 的情况下打开 url 时,它会输出成功,但是一旦我将 index.php 放在 url 中,它只会给出“访问拒绝”作为回应。

例子

It gives me "Access Denied" in response

It gives access denied

It working fine but my all url change took longer time to change

It's working fine

我的 .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>

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

感谢您的光临...

最佳答案

试着把这些放在你的 .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]

关于php - codeigniter url 中的访问被拒绝错误具有 index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52777549/

相关文章:

php - 使用 PHP 设置简单的 A/B 测试

php - 数据库值与数据流不匹配

javascript - <a target ="_blank"> onclick 应该打开一个新选项卡,但焦点应该在当前选项卡上,而不是在新选项卡上,并且应该适用于 chrome 和 mozilla

php - 计算查询中的行数

php - 正则表达式查找最后一组括号之间的数字

apache - 如何使用 .htaccess 将某些 url 重定向到端口

javascript - ionic http POST 不适用于服务器

.htaccess - 所有网站上的 Magento HTTPS : urls redirect to homepage

php - 如何将Chart.js和Chart.min.js嵌入到HTML中

php - 未知列 "in field list form "