我试图用的.htaccess
文件(使用WAMP和Windows 10)使用我的API。我收到了
403禁止
错误。
我的的.htaccess
位于 C / WAMP / WWW /工作
文件:
选项-Indexes
#设定的响应头
< IfModule mod_headers.c>
标题设置访问控制 - 允许 - 起源*
标题设置访问控制 - 允许 - 方法*
< / IfModule>
< IfModule mod_rewrite.c>
#Enable重写引擎
RewriteEngine叙述上
#Rewrite的基地/工作
的RewriteBase /工作
#如果该请求,如果不是在接收机 - 重定向到API服务器
重写规则^ API /(.*)$ API 的index.php?请求= $ 1 [QSA,NC,L]
< / IfModule>
和我的的httpd.conf
文件添加以下
<目录C:/ WAMP / WWW />
#
对于选项指令#可能的值是无,全部,
#或任意组合:
#指标包括了FollowSymLinks SymLinksifOwnerMatch ExecCGI多视图
#
#注意,多视图必须被显式的指定---所有选项
#不给你。
#
#该选项指令既复杂又重要。请参见
#http://httpd.apache.org/docs/2.4/mod/core.html#options
# 了解更多信息。
#
选择指标的FollowSymLinks
#
#的AllowOverride控制什么指令可以被放置在.htaccess文件。
#它可以是全部,无,或关键字的任意组合:
#设置AllowOverride FileInfo的项AuthConfig极限
#
选择了FollowSymLinks指标多视图
设置AllowOverride所有
订购允许,拒绝
允许所有
#
#控制谁可以从服务器获得资料。
#
#onlineoffline标签 - 不要删除
要求所有批准
< /目录>
但我仍然得到一个 403禁止
错误。我知道的.htaccess
文件作品。
也是我的的http://本地主机/工作/
我可以看到所有文件夹除API文件夹
例如请求的URL:本地主机/工作/ API / index.php的运动
这URL不会使给出的指令在你的.htaccess文件太大的意义,因为这将改写为:
/work/api/index.php?request=index.php&campaigns
从我猜想,这是你的API,它是产生403?
在你的.htaccess文件中的指令看起来像它期待是这样的:本地主机/工作/ API /运动
I'm trying to use my API by using .htaccess
file (using WAMP and windows 10). I get a
403 Forbidden
error.
My .htaccess
file located in c/wamp/www/work
:
Options -Indexes
#Set the response headers
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "*"
</IfModule>
<IfModule mod_rewrite.c>
#Enable the Rewrite Engine
RewriteEngine On
#Rewrite the base to /work
RewriteBase /work
#If the request if not for the receiver - redirect to the api server
RewriteRule ^api/(.*)$ apiindex.php?request=$1 [QSA,NC,L]
</IfModule>
and to my httpd.conf
file I added the following
<Directory "c:/wamp/www/">
#
# 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
#
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
#
# Controls who can get stuff from this server.
#
# onlineoffline tag - don't remove
Require all granted
</Directory>
but I still getting a 403 Forbidden
error. I know the .htaccess
file works.
also in my http://localhost/work/
i can see all the folders except api folder
example of the URL requested: localhost/work/api/index.php?campaigns
That URL doesn't make much sense given the directives in your .htaccess file, as it would be rewritten to:
/work/api/index.php?request=index.php&campaigns
From that I would guess that it was your API that was generating the 403?
The directive in your .htaccess file looks like it is expecting something like: localhost/work/api/campaigns
?