Reputation:
AllowOverride
is set to All
and mod_write
is loaded and working (for example if I type some random data in .htaccess
, I get a 500 error), however it's not doing the rewrite, and hence, I get a 404. Why?
htaccess
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule api/(.*)$ api/api.php?id=$1 [QSA,NC,L]
</IfModule>
Tree
/srv/www/htdocs/
├── api
│ ├── api.php
│ ├── .htaccess
│ └── index.php
Directory conf
<Directory "/srv/www/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 None
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
AllowOverride All
# Controls who can get stuff from this server.
<IfModule !mod_access_compat.c>
Require all granted
</IfModule>
<IfModule mod_access_compat.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
An example URL: http://localhost/api/11122233A
There is no error_log
Upvotes: 0
Views: 25
Reputation: 18671
Because .htaccess
is in api
directory, use:
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) api.php?id=$1 [QSA,L]
</IfModule>
Upvotes: 1