I am rewriting a URL in Lighttpd using
url.rewrite-once = (
"^/(.*)\.(.+)$" => "$0",
"^/(.+/?)\??$" => "/index.php?q=$1"
)
So that all urls are passed to index.php as variable q. However when I visit http://mydomain.com/account/edit?user=5 my script at index.php gets
q=account/edit?user=5
on apache I would get all variables i.e.
q=account/edit AND
user=5
How can I preserve the variables in Lighttpd?
(the first part of the url.rewrite rule is to ensure that files that exist are displayed properly)
Try something like this:
"^/something/(\d+)(?:\?(.*))?" => "/index.php?bla=$1&$2"
or this
"^/([^.?]*)\?(.*)$" => "/index.php?q=$1&$2",
"^/([^.?]*)$" => "/index.php?q=$1"
Related
In L4.2, I have been trying to use the phpunit helpers assertRedirectedToRoute() or assertRedirectedToAction(), but they don’t work when there are additional optional params put on the url.
For instance, I have this route:
Route::get('properties/create/{step?}/{property_id?}', [
'as' => 'admin.properties.createStep',
'uses' => 'PropertiesController#createStep']);
However, $this->assertRedirectedToAction(‘App\Controllers\PropertiesController#createStep’) fails with the following response:
1) AdminPropertiesTest::testSearchPostDataWithoutEANPropertyId
Failed asserting that two strings are equal.
--- Expected
+++ Actual
## ##
-'http://localhost/admin/properties/create'
+'http://localhost/admin/properties/create/3/194921'
How do I get an assertion to pass without declaring the "3" or "194921" in the url (as they are dynamic) and using assertRedirectedTo()?
To enable a shorten-url service, I had to add a rewrite rule to my
lighttpd.conf. This seems to be important, otherwise shortlinks like
http://example.com/Xf6Y would return a 404 error. This is because Xf6Y
is not a file but a shortlink hash.
So I added these lines to my lighttpd.conf:
url.rewrite-if-not-file = (
"^/(.*)$" => "/index.php?fwd=$1"
)
This works excellently, except for websites that contain a index.html
instead of an index.php.
I tried to duplicate the rewrite rule, like url.rewrite-if-not-file = (
"^/(.)(\?.)?$" => "/index.php?fwd=$1",
"^/(.)(\?.)?$" => "/index.html?fwd=$1"
)
This resulted in a "duplicate rule" error, so lighttpd is
not able to restart.
Does anyone know how to write a rewrite rule that will redirect index.php and index.html?
I'm trying to remove the index.php from https://test.mysite.com.br/api/index.php/get/0/32342543 with no success.
I've tried:
url.rewrite-once = (
"^/(test)(.*)” => “/$1$2",
"^/(.*)$” => “/index.php/$1"
)
and also:
url.rewrite = (
"^/(.*)\.(.+)$" => "$0",
"^/(.+)/?$" => "/api/index.php/$1"
)
But both didn't work. What is the correct syntax for url.rewrite?
enable lighttpd module "mod_rewrite" in /etc/lighttpd/lighttpd.conf
We have a cakephp app running on 2.0 and we seem to be having some encoding issues with Firefox.
The URL we are accessing is /newcms/core/users/index/conditions[User][group_id]:6 to apply a filter in out cms system.
In everything but FireFox we get the following on the request object
[params] => Array
(
[plugin] => core
[controller] => users
[action] => newcms_index
[named] => Array
(
[conditions] => Array
(
[User] => Array
(
[group_id] => 6
)
)
)
[pass] => Array
(
)
[prefix] => newcms
)
Which is correct and everything works fine, if we goto the same URL in FireFox we get
[params] => Array
(
[plugin] => core
[controller] => users
[action] => newcms_index
[named] => Array
(
[conditions%5BUser%5D%5Bgroup_id%5D] => 6
)
[pass] => Array
(
)
[prefix] => newcms
)
I have tried URL encoding the named condition value but with no luck..
Any suggestions?
It's probably not a great idea to be using brackets and an array structure in your URL.
Why not just use something like this?:
/newcms/core/users/index/user_group:6
Then process the data in the controller.
Well after a bit of digging and playing around the latest version of cake in GitHub has fixed this FF issue (https://github.com/cakephp/cakephp/commit/e6905b44c3d4512b6989c59a1489bc983d88bcdc).
There is nothing incorrect about passing square brackets in the URI it was just an issue with the way FF encoded them differently than the other browsers.
I moved from apache to lighttpd, and since then certain URLs break the rewriting and give 404. No details in access.log, error.log regarding what actual URL was hit.
These kind work:
http://192.168.1.250/loop/rest/admin
But not these:
http://192.168.1.250/loop/rest/admin/logs/file::log-2012-02-14.php
If I skip rewriting and use
http://192.168.1.250/loop/rest/index.php?/admin/logs/file::log-2012-02-14.php
I get what I want,
Here is my rewrite rule:
url.rewrite-once = (
"/(.*)\.(.*)" => "$0",
"/(css|files|img|js|stats)/" => "$0",
"^/([^.]+)$" => "/loop/rest/index.php/$1"
)
Any help would be appreciated.
I was just having the same issues when testing my codeigniter app on lighttpd
This worked for me:
url.rewrite = (
".*\.(js|ico|gif|jpg|png|swf|css|html)$" => "$0",
"^/(.*)$" => "index.php/$1"
)
maybe you could try this for your setup:
url.rewrite = (
".*\.(js|ico|gif|jpg|png|swf|css|html)$" => "$0",
"^/(.*)$" => "/loop/rest/index.php/$1"
)
Make sure you have uncommented mod_rewrite at the top.. it comes default with a # in front of it.
I have found the correct rules:
First of all please make sure that your root directive points to the root of your CI setupd.
root /var/www/loop;
Then this location directive will work perfectly fine:
location /
{
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
}