Clean-URL rewrite rule with nested "location" and alias directive
Ben Johnson
ben at indietorrent.org
Tue Nov 19 18:45:15 UTC 2013
On 11/19/2013 12:38 PM, Francis Daly wrote:
> On Tue, Nov 19, 2013 at 10:36:53AM -0500, Ben Johnson wrote:
>
> Hi there,
>
>> This works as expected, with one major exception: "clean-URL" rewriting
>> does not work. In other words, the homepage (/stage/) loads correctly,
>> but all sub-pages return a 404. As soon as I attempt to add "rewrite"
>> directives for clean-URLs, the server either returns a 500 (redirect
>> cycle) or "Primary script unknown".
>
> Can you give an example of a "clean-URL" that matches the location that
> you use, and that does not do what you want it to do?
>
> Note that your rewrite only happens for urls that end ".php".
>
> f
>
Thanks for your help, Francis!
Certainly: an example URL is /stage/my-account/ . Ultimately, I would
like for this URL to be rewritten to
/stage/index.php?q=/stage/my-account/ (the file "index.php" exists on
the filesystem at /var/www/example.com/private/stage/web/index.php).
Regarding the rewrite happening only for URLs that end in .php, that had
occurred to me, but if I try to move the rewrite "up one level", into
the block "location ^~ /stage/ {", nginx complains upon requesting the
URL /stage/ that '"alias" cannot be used in location "/stage/" where URI
was rewritten'.
Fundamentally, is the problem here that I need to be modifying the
"alias" directive dynamically (with regular expressions and capture
groups), instead of trying to achieve the same with the "rewrite" directive?
Thanks again for your time,
-Ben
More information about the nginx
mailing list