Jump to content
Froxlor Forum
  • 0

NGINX, rewrites, vHosts


bax

Question

Hi!

 

I set up Froxlor on a Debian Wheezy with NGINX and PHP-FPM.

I'm trying to run a site which previously was running on an apache server with the following rewrite rules:

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

I thought about accomplishing the same on NGINX with the following:

 

location / {
    index index.php index.html index.htm;
    try_files $uri $uri/ @rewrites;
}
location @rewrites {
    rewrite ^ index.php?site=$uri&$args last;
}

A minor problem is the added backslash (instead of index.php?site=thread i now get index.php?site=/thread) How could I change that?

 

But my much bigger problem is the way Froxlor manages it's vHost configs. Maybe I just don't get it!

 

Froxlor automatically creates a vHost file for every domain which already contains a rewrite:

 

location @rewrites {
    rewrite ^ /index.php last;
}

My problem is that if I enter the code I would like to work into the domain's vHost entry in the Froxlor panel, the rule gets added AFTER the standard rewrite is done, therefore making my rule obsolete:

location @rewrites {
    rewrite ^ /index.php last;
    rewrite (.*/)?([^/]+)$ $1index.php?site=$2;
}

Is there any way to make my rule work using Froxlor's vHost management?

Can I somehow change the default rewrite or prioritize mine?

There must be a way without changing Froxlor's Cronjobs!

I guess there are many people needing this.

 

Thank you already!

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

 

location / {
    index index.php index.html index.htm;
    try_files $uri $uri/ @rewrites;
}
location @rewrites {
    rewrite ^ index.php?site=$uri&$args last;
}
A minor problem is the added backslash (instead of index.php?site=thread i now get index.php?site=/thread) How could I change that?

 

I don't see any added backslash...

 

Is there any way to make my rule work using Froxlor's vHost management?

Can I somehow change the default rewrite or prioritize mine?

There must be a way without changing Froxlor's Cronjobs!

nope, there is (currently) no other way. nginx and rewrites are very special and vary A LOT. We just cannot make everything work without

breaking something else.

 

I guess there are many people needing this.

not as much as you might think. nginx is fine, but for most hosting plattforms or better most customers need .htaccess and similar and therefore use apache

Link to comment
Share on other sites

d00p, thank you for your reply!

 

Somehow a backslash is being added: Apache threw out  /index.php?site=requestedsite whereas NGINX throws /index.php?site=/requestedsite

Maybe there's something in my rule I'd have to change?

 

But if I change the cron every domain will have this added to it's rewrites, am I right?

Link to comment
Share on other sites

You mean a SLASH "/", a backslash would be "\". And it's in the parameter, so your request for the parameter seems to include the prefixed-slash

Sorry, you're absolutely right about the slash and the backslash.

 

But where is it in the parameter?

 

If I go to www.mysite.com/requestedsite the GET is "site=/requestedsite", not (as before) "site=requestedsite"?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.



×
×
  • Create New...