我想http://localhost/api/v1/example重定向到http://localhost/api/v1/api.php?request=example
我有以下但的.htaccess它不工作:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule api/v1/(.*)$ api/v1/api.php?request=$1 [QSA,NC,L]
</IfModule>
我使用服務器:Apache/2.4.10(Unix的)PHP/5.5.14在Mac上的優勝美地。我註釋掉了的LoadModule mod_rewrite的,並設置了AllowOverride所有:
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
#
# 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 FollowSymLinks Multiviews
MultiviewsMatch Any
#
# 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>
任何幫助,將不勝感激!
@anubhava/Library/WebServer/Do作爲我的PHP文件的地方 相同的地方。 –
是的,給我500錯誤,所以它正在使用@anubhava –
你必須使用Apache 2.4,而不是2.2。 「要求所有授予的」在2.2中不存在,並且如果使用將會引發錯誤。請確認您使用的是哪個版本。 –