Welcome! Log In Create A New Profile


help with rewrite

Posted by Usu 
help with rewrite
August 13, 2009 10:00AM
I'm working on the new version of my site and when it'll be released I'll need to have redirect set up for the forum old URLs in order to keep the pages indexed by google.

atm the forum URLs are based on the joomla bridge (the smf developed one) so a board URL looks like this: http://www.italiansubs.net/index.php?option=com_smf&Itemid=26&board=132.0

in the next version of the site the forum won't be wrapped in joomla anymore so the above URL will become this: http://www.italiansubs.net/forum/index.php?board=132.0

I wrote this rule in nginx configuration file to begin testing redirection on a testing subdomain:

location / {
index index.php;
rewrite ^/index\.php\?option=com_smf&Itemid=26&board=([0-9]*)$ /forum/index.php?board=$1.0 last;

but it doesn't work, it doesn't even redirect to anything, it's like it doesn't recognize the first url in the rewrite rule :'(

are there any other characters to be escaped besides "." and "?" ?
am I doing something else wrong?
any help would be really appreciated :)
Re: help with rewrite
August 13, 2009 04:02PM
Ok, I figured that nginx can't handle the rewrite of an URL that contains a question mark like this: index.php[b][color=#FF0033]?[/color][/b]option=com_smf&Itemid=26&board=132.0

all the parameters after the question mark are being ignored and treated as $query_string

The only topic I've found regarding the matter is this: http://www.ruby-forum.com/topic/152723 I use fastcgi but I can't really understand how to apply that to my case :(

Any hints? Thank you.
Re: help with rewrite
August 14, 2009 06:54AM
I finally got it working!

Here's the rewrite code:

location ~ \.php$ {

if ($query_string ~ "option=com_smf&Itemid=26&board=([^/]+)?$") {
set $var $1;
rewrite ^/index\.php$ /forum/index.php?board=$var permanent;
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 86
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready