1

I want to serve

http://172.16.0.2/container/app.html/any/path/here by app.html which is an existing resource.

Plus, I want all my path without any ending extention to be served by index.html. I.e.: http://172.16.0.2/container/path/randomly/written

here are my rules:

Options -MultiViews

RewriteEngine On

RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]

RewriteRule ^[^.]{1}(?!<\.)[^.]{1,}$   index.html [L]

RewriteRule ^app.html$   - [L]
RewriteRule ^app.html(.*)$   app.html [L]

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule - [L]
  • Requesting app.html works
  • Requesting index.html works
  • Requesting index.html/path/pathpath works (index.html)
  • Requesting index.html/path/pathpath.EXT works (404)

BUT

  • Requesting app.html/a/path generates a 404 error.

No clue at all, can someone explain me why?

Logs

172.16.0.1 - - [27/Jul/2016:10:44:40 +0000] [172.16.0.2/sid#7fc44d87d4c0][rid#7fc44dbd10b8/initial] (3) [perdir /var/www/html/applications/container/web/] add path info postfix: /var/www/html/applications/container/web/app.html -> /var/www/html/applications/container/web/app.html/sdf/sdf
172.16.0.1 - - [27/Jul/2016:10:44:40 +0000] [172.16.0.2/sid#7fc44d87d4c0][rid#7fc44dbd10b8/initial] (3) [perdir /var/www/html/applications/container/web/] strip per-dir prefix: /var/www/html/applications/container/web/app.html/sdf/sdf -> app.html/sdf/sdf
172.16.0.1 - - [27/Jul/2016:10:44:40 +0000] [172.16.0.2/sid#7fc44d87d4c0][rid#7fc44dbd10b8/initial] (3) [perdir /var/www/html/applications/container/web/] applying pattern '^app.html(.*)$' to uri 'app.html/sdf/sdf'
172.16.0.1 - - [27/Jul/2016:10:44:40 +0000] [172.16.0.2/sid#7fc44d87d4c0][rid#7fc44dbd10b8/initial] (2) [perdir /var/www/html/applications/container/web/] rewrite 'app.html/sdf/sdf' -> 'app.html'
172.16.0.1 - - [27/Jul/2016:10:44:40 +0000] [172.16.0.2/sid#7fc44d87d4c0][rid#7fc44dbd10b8/initial] (3) [perdir /var/www/html/applications/container/web/] add per-dir prefix: app.html -> /var/www/html/applications/container/web/app.html
172.16.0.1 - - [27/Jul/2016:10:44:40 +0000] [172.16.0.2/sid#7fc44d87d4c0][rid#7fc44dbd10b8/initial] (1) [perdir /var/www/html/applications/container/web/] initial URL equal rewritten URL: /var/www/html/applications/container/web/app.html [IGNORING REWRITE]
Bertuz
  • 2,390
  • 3
  • 25
  • 50

1 Answers1

0

The problem is that those rules are set into a <Directory> directive, after some previous RewriteRule set before the <Directory> directive and just straight into the <VirtualHost> directive.

According to the documentation, if I set a RewriteRule in there, I can only rewrite by specifying URLs. I was specifying by thinking about the physical path, though.

Designates the location on the file-system of the resource to be delivered to the client. Substitutions are only treated as a file-system path when the rule is configured in server (virtualhost) context and the first component of the path in the substitution is exists in the file-system

Two solutions:

  • Thinking about URL rewrite
  • Move the RewriteRule outside the <Directory> directive so that the substitution is well considered as physical path by apache
Bertuz
  • 2,390
  • 3
  • 25
  • 50