Welcome! Log In Create A New Profile

Advanced

Redirect all request to index.php and $_GET variables

Posted by curiosus 
Redirect all request to index.php and $_GET variables
October 17, 2012 01:57PM
I am using the following to redirect all request to index.php

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

This works on the following:

example.com/foo
example.com/foo/bar/et

but it doesn't work on:

example.com/foo?bar
example.com/foo?bar=quz

To summarize what I need, the following:

example.com/foo
example.com/foo/bar/etc
example.com/foo?bar
example.com/foo?bar=quz

should all serve index.php "silently" without changing the URL of the browser's address bar.

Additionally, when calling:

example.com/foo?bar=quz

PHP's $_GET variable should have bar => quz as the value.

Anybody knows how to make this work in the rewrite rule?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 177
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