0

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>
harsha
  • 33
  • 8
  • Does this answer your question? [Forbidden You don't have permission to access / on this server](https://stackoverflow.com/questions/21551840/forbidden-you-dont-have-permission-to-access-on-this-server) – jobayersozib May 13 '20 at 06:57
  • I have tried the following example but still, my problem is not solved – harsha May 13 '20 at 07:14

1 Answers1

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

sauhardnc
  • 1,961
  • 2
  • 6
  • 16
  • No, It possible to create dynamic ServerRoot And ${SRVROOT} is part of the syntax, Not PHP variable. please check the link for more details https://www.apachelounge.com/viewtopic.php?p=36957 – harsha May 13 '20 at 15:49
  • what is `${SRVROOT}` defined with? @harsha – sauhardnc May 13 '20 at 16:11
  • Define SRVROOT "C:/Apache24" ServerRoot "${SRVROOT}" Way to declare dynamic path in httpd.conf So whenever I call ${SRVROOT} it will call the C:/Apache24 – harsha May 14 '20 at 08:15
  • are you using xampp? – sauhardnc May 14 '20 at 08:28
  • No directly installed apache and php 7.0, I have other projects from scriptcase are running on that server, So some one from my team modified the httpd.conf and php.ini file according to scriptcase – harsha May 14 '20 at 09:43
  • I've updated my httpd.conf file in the answer. If it doesn't get your project to run then I don't think the error is due to `httpd.conf` file – sauhardnc May 14 '20 at 10:11
  • Without .htaccess file i am able to run my project, with .htaccess file it showing forbidden don't have access to the /mpnsearch/ server – harsha May 14 '20 at 10:30