0

Help rewrite flag apache - QSA for lighttpd. Now available:

RewriteRule ^([^?]*) index.php?_route_=$1 [L, QSA]

Try the case, but is not functioning properly:

url.rewrite-if-not-file = ("^/(?:\?(.*))?" => "/index.php?_route_=$1")
jeka5555
  • 189
  • 1
  • 15

1 Answers1

1

From what I understand of lighttpd:

url.rewrite-if-not-file = ("^/([^\?]*)$" => "/index.php?_route_=$1")

.. should work. If not, then the following will:

url.rewrite-if-not-file = ("^([^\?]*)$" => "/index.php?_route_=$1")
Timo Tijhof
  • 10,032
  • 6
  • 34
  • 48
Jon
  • 4,746
  • 2
  • 24
  • 37
  • This version does not work. If the URL is present in a question mark, I get a 404 page – jeka5555 Oct 17 '12 at 05:54
  • `^([^\?]+)[\?]{0,1}(.*)$` and $1 would relate to the file, ie `index.php` and $2 would relate to the query, ie `index.php?myvar=test` it would match the `myvar=test` part. – Jon Oct 17 '12 at 06:05
  • (I am assuming you already tried `^(.*)$` to match everything inputed... ) – Jon Oct 17 '12 at 06:11
  • yes, this is the first thing I tried. In this case, $ _GET when requested, for example: http://host.com/tea/white_tea/?sort=pd.name&order=ASC $ _GET Contains: ["_route_"] => "tea / white_tea /? sort = pd.name" ["order"] => "ASC" While it is expected: ["_route_"] => "tea / white_tea /" ["sort"] => "pd.name" ["order"] => "ASC" – jeka5555 Oct 17 '12 at 06:20
  • Then try... `url.rewrite-if-not-file = ("^([^\?]+)[\?]{0,1}(.*)$" => "/index.php?route=$1&$2"` – Jon Oct 17 '12 at 06:25
  • Now, if you ask, for example: [link](http://chinachay.rework.pro/tea/white_tea/?sort=pd.name&order=ASC) I redirect (301) to [link](http://chinachay.rework.pro/index.php?route=/tea/white_tea/&sort=pd.name&order=ASC) See for yourself the related links. – jeka5555 Oct 17 '12 at 06:40
  • I can't really read the page...but from what I can tell...it seems to be working? `http://chinachay.rework.pro/tea/black_tea/&sort=pd.name&order=ASC` does a redirect correctly. – Jon Oct 17 '12 at 06:48
  • 1
    Thank you! Understood. Just in case your minor typo, do this: `(url.rewrite-if-not-file = ("^([^\?]+)[\?]{0,1}(.*)$" => "/index.php?_route_=$1&$2")` – jeka5555 Oct 17 '12 at 06:54
  • Ahh, yes the `_route_`, I had removed the underscores because you said `While it is expected: ["route"] => "tea / white_tea /" ["sort"] => "pd.name" ["order"] => "ASC"` so I assumed you wanted the underscores gone. :) But add them back if needed, and it should work as you want ^^ – Jon Oct 17 '12 at 06:56
  • When your questions are answered, don't forget to mark them as 'accepted'. ^^ I noticed you haven't done that with any questions you've asked. Just letting you know that's the best accepted practice. ^^ – Jon Oct 17 '12 at 07:16