简体   繁体   中英

.htaccess file causing forbidden error in my codeigniter application, I am running apache 24 in my windows server

Without the .htaccess file the application running perfectly, Whenever I add .htaccess file it showing forbidden don't have access to the / server. I tried to put "Test." in the first line of .htaccess file it "showing Internal server error" that's good apache reading .htaccess file. But whenever it read "RewriteEngine on" line in .htaccess file immediately it showing forbidden error.

here is my .htaccess file.

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

And httpd.config file

   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. There is no need to change httpd.conf file, .htaccess file is enough to make your CI project up and running.
  2. But if you must, you need to give absolute path in DocumentRoot ie change ${SRVROOT}/htdocs to "F:/xampp/htdocs" -- (your/location/here)
  3. ${SRVROOT} will not work as you are not writing in a .php file.

See these for more info --

This is my httpd.conf file -

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>

my .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

Hope this helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM