Bug 60159 - mod_rewrite rules not executed
Summary: mod_rewrite rules not executed
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_rewrite (show other bugs)
Version: 2.4.17
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-20 22:22 UTC by Shravan Rajinikanth
Modified: 2016-09-21 04:36 UTC (History)
0 users



Attachments
conf (1.15 KB, text/plain)
2016-09-20 22:22 UTC, Shravan Rajinikanth
Details
testcase (1.61 KB, application/octet-stream)
2016-09-21 04:34 UTC, Shravan Rajinikanth
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Shravan Rajinikanth 2016-09-20 22:22:26 UTC
Created attachment 34283 [details]
conf

[First post, advise where needed.]

I have a server with the following structure:

- root/
    - api/
        - products/
            - index.php
    - include/
        ...
    - index.php

The server is setup to use a virtual host which "Include"s a seaparate .conf file attached below. I can confirm that the conf file is read. But when the url is http://example.com/api/products, it 404s. The log contains just these 2 lines:

[Tue Sep 20 22:19:13.066519 2016] [rewrite:trace2] [pid 6024:tid 1016] mod_rewrite.c(476): [client x.x.x.x:28438] x.x.x.x - - [example.com/sid#6595032cc8][rid#65958b8330/initial] init rewrite engine with requested uri /api/products
[Tue Sep 20 22:19:13.066519 2016] [rewrite:trace1] [pid 6024:tid 1016] mod_rewrite.c(476): [client x.x.x.x:28438] x.x.x.x - - [example.com/sid#6595032cc8][rid#65958b8330/initial] pass through /api/products

i.e. the RewriteRules set for /api/products aren't even run.

The following questions were from a few days back when I was trying to get this to work via .htaccess files. They might provide more clues to the issue.

https://stackoverflow.com/questions/39402343/mod-rewrites-in-nested-htaccess-causing-strange-404
https://serverfault.com/questions/802301/mod-rewrites-in-nested-htaccess-causing-strange-404 (A user here believes this is a bug with DirectorySlash)
Comment 1 Eric Covener 2016-09-21 00:35:16 UTC
Convince me those <Directory> sections match at all.
Comment 2 Shravan Rajinikanth 2016-09-21 01:38:18 UTC
Eric, calling an actually non-existant URL like "/api/produc" instead of "/api/products" still gives me a 404, but a completely different log output (below).

Further, removing the directory directive causes the index.php page to load instead of 404'ing. 

[Wed Sep 21 01:28:33.978593 2016] [rewrite:trace2] [pid 6024:tid 1012] mod_rewrite.c(476): [client x.x.x.x:31018] x.x.x.x - - [example.com/sid#6595032cc8][rid#65958aa2c0/initial] init rewrite engine with requested uri /api/produc
[Wed Sep 21 01:28:33.978593 2016] [rewrite:trace1] [pid 6024:tid 1012] mod_rewrite.c(476): [client x.x.x.x:31018] x.x.x.x - - [example.com/sid#6595032cc8][rid#65958aa2c0/initial] pass through /api/produc
[Wed Sep 21 01:28:33.978593 2016] [rewrite:trace3] [pid 6024:tid 1012] mod_rewrite.c(476): [client x.x.x.x:31018] x.x.x.x - - [example.com/sid#6595032cc8][rid#65958aa2c0/initial] [perdir C:/Workbench/Webserver/example.com/api/] strip per-dir prefix: C:/Workbench/Webserver/example.com/api/produc -> produc
[Wed Sep 21 01:28:33.978593 2016] [rewrite:trace3] [pid 6024:tid 1012] mod_rewrite.c(476): [client x.x.x.x:31018] x.x.x.x - - [example.com/sid#6595032cc8][rid#65958aa2c0/initial] [perdir C:/Workbench/Webserver/example.com/api/] applying pattern '^(.+)(?<!/)$' to uri 'produc'
[Wed Sep 21 01:28:33.978593 2016] [rewrite:trace4] [pid 6024:tid 1012] mod_rewrite.c(476): [client x.x.x.x:31018] x.x.x.x - - [example.com/sid#6595032cc8][rid#65958aa2c0/initial] [perdir C:/Workbench/Webserver/example.com/api/] RewriteCond: input='C:/Workbench/Webserver/example.com/api/produc/' pattern='-d' => not-matched
[Wed Sep 21 01:28:33.978593 2016] [rewrite:trace1] [pid 6024:tid 1012] mod_rewrite.c(476): [client x.x.x.x:31018] x.x.x.x - - [example.com/sid#6595032cc8][rid#65958aa2c0/initial] [perdir C:/Workbench/Webserver/example.com/api/] pass through C:/Workbench/Webserver/example.com/api/produc
Comment 3 Eric Covener 2016-09-21 02:19:08 UTC
Will need a complete, minimal self-contained test case to get anywhere with this as a bug report.
Comment 4 Shravan Rajinikanth 2016-09-21 02:41:39 UTC
What would that include? Just the config files and server root? (Sure, I can get this to you soon, but really, everything is already here.)
Comment 5 Eric Covener 2016-09-21 02:44:19 UTC
(In reply to Shravan Rajinikanth from comment #4)
> What would that include? Just the config files and server root? (Sure, I can
> get this to you soon, but really, everything is already here.)

A single, minimal config file you can pass to apachectl -f that demonstrates the problem +  small zip of the documentroot it references.  

I'm not doubting that it fails for you, but I won't be able to keep trying different permutations of all the unspecified stuff to do anything here without it.
Comment 6 Shravan Rajinikanth 2016-09-21 04:34:29 UTC
Created attachment 34285 [details]
testcase
Comment 7 Shravan Rajinikanth 2016-09-21 04:36:32 UTC
I have posted the test case after cleaning up as much as I could. I was able to isolate that the "RewriteEngine On" line is causing the issue and indicated it. You can see this by commenting out the one line.