windows - .htaccess 文件在我的 codeigniter 应用程序中导致禁止错误,我在我的 Windows 服务器中运行 apache 24
问题描述
如果没有 .htaccess 文件,应用程序运行完美,每当我添加 .htaccess 文件时,它显示禁止访问 / 服务器。我试着输入“测试”。在 .htaccess 文件的第一行中,它“显示内部服务器错误”这是很好的 apache 读取 .htaccess 文件。但是,每当它立即读取 .htaccess 文件中的“RewriteEngine on”行时,它就会显示禁止错误。
这是我的 .htaccess 文件。
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
和 httpd.config 文件
DocumentRoot "${SRVROOT}/htdocs"
<Directory "${SRVROOT}/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
Options ExecCGI
</Directory>
解决方案
- 无需更改
httpd.conf
文件,.htaccess
文件足以使您的CI
项目启动并运行。 - 但如果你必须,你需要给出绝对路径,
DocumentRoot
即更改${SRVROOT}/htdocs
为"F:/xampp/htdocs" -- (your/location/here)
${SRVROOT}
将无法工作,因为您没有在.php
文件中写入。
有关更多信息,请参阅这些-
- 如何为apache服务器设置codeigniter?
- 设置 httpd.conf / mod_rewrite 以重定向到 codeigniter?
- 如何更正配置 Apache 和 Codeigniter?
这是我的httpd.conf
文件-
DocumentRoot "F:/xampp/htdocs"
<Directory "F:/xampp/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks Includes ExecCGI
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
我的.htaccess
——
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1
# if your base_url() doesn't have a trailing slash then instead of ↑ use ↓-
# RewriteRule (.*) /index.php/$1
希望这对您有所帮助。
推荐阅读
- vba - 仅获取 VBA 中的数值
- flutter - 如果我们在 App 中使用了很多插件,是否有机会减慢 Flutter 中的应用程序?
- reactjs - 将值从一个下拉列表传递到另一个下拉列表
- c# - C# 队列管理服务覆盖值
- java - 在 Java 中提交作业时,如何解决 Spark 作业服务器中的“作业加载失败”错误?
- c++ - 定义变量 esp32
- html - 在 Zendesk hbs 中注入 Webfont 图标
- java - 我应该在 EntityManager.detach() 上使用 JPA EntityManager.clear()
- c++ - 我认为我的变量没有正确分配
- python - 如何实现具有点到面距离的 ICP