.htaccess文件导致我的codeigniter应用程序中禁止的错误,我正在Windows服务器中运行apache



如果没有.htaccess文件,应用程序可以完美运行, 每当我添加 .htaccess 文件时,它都显示禁止访问/服务器。 我试图将"测试"放在.htaccess文件的第一行,它"显示内部服务器错误",这是很好的apache读取.htaccess文件。 但是每当它在.htaccess文件中读取"重写引擎"行时,它就会立即显示禁止的错误。

这是我的.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>
  1. 无需更改httpd.conf文件,.htaccess文件是 足以使您的CI项目启动并运行。
  2. 但是,如果必须,则需要在DocumentRoot中提供绝对路径,即将${SRVROOT}/htdocs更改为"F:/xampp/htdocs" -- (your/location/here)
  3. ${SRVROOT}将不起作用,因为您不是在.php文件中写入。

有关更多信息,请参阅这些 --

  • 如何为阿帕奇服务器设置代码点火器?
  • 设置 httpd.conf/mod_rewrite 以重定向到代码点火器?
  • 如何纠正配置 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

希望这对你有帮助。

相关内容

  • 没有找到相关文章

最新更新