Welcome! Log In Create A New Profile

Advanced

a bit confused with rewrite rules

Posted by keepitcoder 
a bit confused with rewrite rules
August 27, 2010 02:25AM
hat I'm trying to accomplish, is to have people who go to: http://www.mydomain.com/$SEARCH-QUERY/$PAGE-NUMBER to redirect to search.php?query=SEARCH-QUERY&page=PAGE-NUMBER

I just figured out how to install nginx and configure php-fpm, mysql and everything, but now I'm a bit confused over the rewrites. Here's what I have, that doesn't appear to work correctly:

the php script will automatically assume it's the first page if no page query is sent with it, also I had to do two rewrite rules as I couldn't figure out how to implement it on one line so that it can have it with and without the trailing slash.

[code]
rewrite ^/search/(.*)$ /search.php?query=$1;
rewrite ^/search/(.*)$/ /search.php?query=$1;
[/code]


and then for items viewed with paged results

[code]
rewrite ^/search/(.*)/(.*)$ /search.php?query=$1&page=$2;
rewrite ^/search/(.*)/(.*)$/ /search.php?query=$1&page=$2;
[/code]


If anyone could please help, I'd appreciate it greatly!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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