Welcome! Log In Create A New Profile

Advanced

Rewrite for sNews 1.7 (Port)

Posted by Zhang 
Rewrite for sNews 1.7 (Port)
July 31, 2011 05:23PM
Hello fellow nginx users,

i currently port a project from Apache to nginx which runs on sNews ( http://snewscms.com/ )
Since 2 weeks i try now to get the damn rewrite ported, but i have no luck at all.

i use Nginx 1.0.5 stable, on Debian 6 64bit, with --configure:
--conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_stub_status_module --with-http_flv_module --with-http_ssl_module --with-http_dav_module --with-http_gzip_static_module --with-http_realip_module --with-mail --with-mail_ssl_module --with-ipv6


This is the original Apache htaccess:

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*) $1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?category=$1 [L]

Basically everything needs to be rewritten to index.php?category=$REQUEST - as example:
http://nohostsland.com/europe/belarusian-19-512mb-ram-kvm-vps/
-->
http://nohostsland.com/index.php?category=europe/belarusian-19-512mb-ram-kvm-vps

My current rewrite DOES work for this, it rewrites them correctly (i can access it over /europe/belarusian-19-512mb-ram-kvm-vps/) however it breaks ANY files in subfolders or even files at parent directory - and i simply have no idea why.

Thats what i use currently:

if (!-f $request_filename ) {
rewrite ^/(.*)$ /index.php?category=$1 last;
}

With !-e it wont react at all to it, with -d of course only partly - so i seem to need to use -f.

I would appreciate any help in this matter..... i am out of ideas.

Thanks!
Zhang
Re: Rewrite for sNews 1.7 (Port)
August 30, 2011 02:06PM
And here it is:

location / {
index index.html index.php;
if (-f $request_filename) {
break;
}
if (!-f $request_filename) {
rewrite ^/(.+)$ /index.php?category=$1 last;
break;
}
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 261
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready