anyone got a nginx rewrite config ?

Problems with basic installation

anyone got a nginx rewrite config ?

Postby hayden » Sun Jan 13, 2013 12:52 am

to replace the functionality of the default apache .htaccess file ?

thanks.
hayden
 
Posts: 96
Joined: Wed Oct 22, 2008 12:17 pm
Location: Sydney, Australia

Re: anyone got a nginx rewrite config ?

Postby afz » Sun Jan 13, 2013 5:40 am

Code: Select all
# redirect www to non-www for port 80
server {
    server_name ~^www\.;
    rewrite ^ $scheme://$domain$request_uri permanent;

    # checking for the existence of a file, directory or symbolic
    # working without index.php
    try_files $uri $uri/ /index.php/$uri;
}

instead of $domain put your domain name
afz
 
Posts: 694
Joined: Sat Apr 12, 2008 1:46 am

Re: anyone got a nginx rewrite config ?

Postby hayden » Sun Jan 13, 2013 7:36 am

thank you so much, ill try this right away.
hayden
 
Posts: 96
Joined: Wed Oct 22, 2008 12:17 pm
Location: Sydney, Australia

Re: anyone got a nginx rewrite config ?

Postby hayden » Sun Jan 13, 2013 7:43 am

im thinking now though i have other issue to fix first before i try to get rewrite working,

as even: http://httech.com.au/index.php/page/Profile.html (not requireing rewirte) fails with a 404 error

2013/01/13 16:19:47 [error] 5170#0: *123 open() "/public_html/index.php/page/Profile.html" failed (20: Not a directory), client: ip, server: httech.com.au, request: "GET /index.php/page/Profile.html HTTP/1.1", host: "httech.com.au", referrer: "http://httech.com.au/"

any ideas ?
hayden
 
Posts: 96
Joined: Wed Oct 22, 2008 12:17 pm
Location: Sydney, Australia

Re: anyone got a nginx rewrite config ?

Postby afz » Sun Jan 13, 2013 7:47 am

your nginx is very old, i am not familiar older than 1.x
afz
 
Posts: 694
Joined: Sat Apr 12, 2008 1:46 am

Re: anyone got a nginx rewrite config ?

Postby hayden » Sun Jan 13, 2013 12:30 pm

ok ,thanks all the same, maybe ill look into upgrading if possible
hayden
 
Posts: 96
Joined: Wed Oct 22, 2008 12:17 pm
Location: Sydney, Australia

Re: anyone got a nginx rewrite config ?

Postby hayden » Tue Jan 15, 2013 12:01 pm

well after a serverfault question i was supplied with this that works when using index.php in your links:

Code: Select all
location ~ \index.php/ {
    try_files $uri $uri/ /index.php;
    fastcgi_pass localhost:9000;
}
location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass localhost:9000;
}
hayden
 
Posts: 96
Joined: Wed Oct 22, 2008 12:17 pm
Location: Sydney, Australia

Re: anyone got a nginx rewrite config ?

Postby hayden » Thu Jan 17, 2013 11:27 am

well got it working without index.php in the url as well with this:

Code: Select all
location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass localhost:9000;
}
location ~ \index.php/ {
    try_files $uri $uri/ /index.php;
    fastcgi_pass localhost:9000;
}
location / {
  try_files $uri $uri/  /index.php/$uri; 
}
hayden
 
Posts: 96
Joined: Wed Oct 22, 2008 12:17 pm
Location: Sydney, Australia


Return to Installation

Who is online

Users browsing this forum: No registered users and 1 guest

cron