Welcome! Log In Create A New Profile

Advanced

Rewrite rules for lithium framework

Posted by liepumartins 
Rewrite rules for lithium framework
May 25, 2012 08:45AM
I would like to deploy lithium framework on nginx (with php-fpm), however I'm stuck transforming .htaccess rules to nginx.

Framework has following structure:

/
|-.htaccess (#1)
|-index.php (requires next index.php)
|-app/
| |-.htacces (#2)
| |-index.php (just requires next index.php)
| |-webroot/
| | |-.htaccess (#3)
| | |-index.php (the one that finally handles requests)


.htaccess #1
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]

.htaccess #2
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]

.htaccess #3
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !favicon.ico$
RewriteRule ^ index.php [QSA,L]


Thus far I've created following rules:

location / {
rewrite ^$ /app/webroot/;
rewrite (.*) /app/webroot/$1;
}

location /app/ {
rewrite ^$ webroot/;
rewrite (.*) webroot/$1;
}

location /app/webroot/ {
index index.php;
try_files $uri $uri/ /index.php;
### OR ###
rewrite ^ index.php last;
}

But those are (completely?) wrong. Either application cannot access static files, all links become http://index.php/something or links get appended to current URL.
What am I doing wrong?

Please, can someone help me get on the right track.

import antigravity



Edited 1 time(s). Last edit at 05/25/2012 08:46AM by liepumartins.
Re: Rewrite rules for lithium framework
June 21, 2012 10:52AM
UPDATE

Changed root to directory "webroot", so now I need less rules.

root /var/servers/my_app/app/webroot;
# previously it was
# root /var/server/my_app;

location / {
index index.php;
try_files $uri $uri/ index.php;
}
location ~ \.php {
fastcgi_pass unix:/tmp/php.socket;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/servers/my_app/$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
}

This, however, still does not do the trick.
If I access / (root page), all the links has index.php
e.g. Instead of "www.example.com/test" there is link "www.example.com/index.php/test",
also resource links (js, css) are "/index.php/css/lithium.css" instead of "/css/lithium.css".

Interesting, that when I access www.example.com/test (via direct URL input), the page is displayed correctly - links become "./css/lithium.css" (yes, with a dot).
Re: Rewrite rules for lithium framework
June 25, 2012 03:04AM
UPDATE2:

Thanks to people who pointed out wiki article http://lithify.me/docs/manual/configuration/servers/nginx.wiki

However provided configuration still doesn't resolve issue with "index.php" getting perpended to links.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 219
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready