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

问题描述 投票:0回答:1

在没有.htaccess文件的情况下,应用程序运行得很完美,每当我添加.htaccess文件时,它都显示禁止访问服务器.我试着在.htaccess文件的第一行加上 "Test.",它 "显示内部服务器错误",这是很好的apache读取.htaccess文件.但每当它读取.htaccess文件中的 "RewriteEngine on "行时,它立即显示禁止错误。

这是我的.htaccess文件,还有httpd.config文件。

 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>
windows apache .htaccess codeigniter
1个回答
0
投票
  1. 没有必要改变 httpd.conf 文件。.htaccess 文件足以让你的 CI 项目启动和运行。
  2. 但如果你必须要这样做,你需要在 DocumentRoot 即改变 ${SRVROOT}/htdocs"F:/xampp/htdocs" -- (your/location/here)
  3. ${SRVROOT} 将无法工作,因为你不是在一个 .php 文件。

更多信息请看这些 --

这是我的 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

希望对你有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.