Daniel B.
Daniel B.

Reputation: 1680

URL-encoded parameter breaks default Zend rewrite rules

I'm using the standard Zend /public/.htaccess file (shown below).

At the moment I'm attempting to forward the user to a specific controller/action, and supply the on-success-redirect URL as a URL parameter.

The resulting URL (assembled & encoded via Zend's URL view helper) looks like this:

localhost/crop/index/successRedirect/localhost%2Fprofile%2Fbasic

However this pattern apparently violates the default, Zend package mod_rewrite rules: accessing the URL yields a standard Apache 404 error; Zend doesn't receive the request.

When the final parameter is manually re-formed as follows, the request works as desired:

localhost/crop/index/?successRedirect=localhost%2Fprofile%2Fbasic

However this requires a hackish, two-step URL generation process. It would be ideal if the URL produced by the view helper worked independently.

What can be done to permit the url-encoding to pass through? Any insight would be appreciated!

These are the contents of my .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Enabling RewriteLog like so produces no output for the failing pattern:

RewriteLogLevel 9
RewriteLog "<path>/rewrite.log"

I've attempted the solutions proposed by the following two Q&A's, with no change:

Upvotes: 5

Views: 4253

Answers (1)

Tim Fountain
Tim Fountain

Reputation: 33148

AllowEncodedSlashes On fixed this for me, using your exact test URL. However as per http://httpd.apache.org/docs/2.0/mod/core.html#allowencodedslashes, this directive needs to be in either the server configuration or vhost. it doesn't work in the .htaccess file.

Personally I would go with the query string solution. Could you expand on what you mean by this being a two-step URL generation process? I would have thought the syntax would be pretty similar to using the normal URL helper.

Upvotes: 4

Related Questions