Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • Adding encoded chars to the url breaks htaccess (AllowEncodedSlashes On)
  • Mod Rewrite and Using PHP's GET for URL's When not Following the Rules (use QSA directive for rewrite rule)
like image 656
Daniel B. Avatar asked Oct 08 '22 19:10

Daniel B.


1 Answers

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.

like image 85
Tim Fountain Avatar answered Oct 13 '22 11:10

Tim Fountain