![](/img/trans.png)
[英]Is a htaccess file different on apache running on a windows server
[英].htaccess file causing forbidden error in my codeigniter application, I am running apache 24 in my windows server
如果沒有 .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
文件。 有關更多信息,請參閱這些-
這是我的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
希望這對您有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.