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;
}
}
Related
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
I'm trying to implement nginx rewrite rules for the following situation
Request:
http://192.168.64.76/Shep.ElicenseWeb/Public/OutputDocuments.ashx?uinz=12009718&iinbin=860610350635
Should be redirected to:
http://localhost:82/Public/OutputDocuments.ashx?uinz=12009718&iinbin=860610350635
I tried this with no luck:
location /Shep.ElicenseWeb/ {
rewrite ^/Shep.ElicenseWeb/ /$1 last;
proxy_pass http://localhost:82;
}
What is the correct way to perform such a rewrite for nginx ?
Your rewrite statement is wrong.
The $1 on the right refers to a group (indicated by paratheses) in the matching section.
Try:
rewrite ^/Shep.ElicenseWeb/(.*) /$1 break;
You're missing a trailing slash:
location /Shep.ElicenseWeb/ {
proxy_pass http://localhost:82/;
}
This will work without a rewrite.
I want people type in http://www.myweb.com/like/1234456 will redirect to
http://www.myweb.com/item.php?itemid=1234456
I wrote something like this in the config but it doesn't work.
location = ^~/like/ {
rewrite ^1234456 ../likeitem.php?item=1234456break;
return 403;
}
this is just a test. I haven't used the $ matching yet.
I also restart my ngnix server but still.. it doesn't do the redirect.
The code above will not work because of a missing $ and poor use of the return command.
The code below works with Nginx, including version 0.8.54.
Format below is :
DesiredURL
Actual URL
Nginx_Rule
They must be inside location / {}
http://example.com/notes/343
http://example.com/notes.php?id=343
rewrite ^/notes/(.*)$ /notes.php?id=$1 last;
http://example.com/users/BlackBenzKid
http://example.com/user.php?username=BlackBenzKid
rewrite ^/users/(.*)$ /user.php?username=$1 last;
http://example.com/top
http://example.com/top.php
rewrite ^/top?$ /top.php last;
Complex and further
http://example.com/users/BlackBenzKid/gallery
http://example.com/user.php?username=BlackBenzKid&page=gallery
rewrite ^/users/(.*)/gallery$ /user.php?username=$1&page=gallery last;
Try this,
server {
server_name www.myweb.com;
rewrite ^/like/(.*) http://www.myweb.com/item.php?itemid=$1 permanent;
}
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"