Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Tue Jul 13, 2010 12:57 pm 
Offline
Senior Newbie

Joined: Sun Jun 21, 2009 1:48 pm
Posts: 16
Website: http://www.hardware-revolution.com
WLM: gamecubemanrules@hotmail.com
Location: Montreal, Quebec, Canada
Hey everyone,

I have been with Linode since June 2009, on what used to be a 720 (now 1024) and I'm loving it.

Now, I'm trying to build a new web server, on Ubuntu 10.04 LTS, with PHP-FPM (Separate) Installed from Source and Nginx as the web server. I've got everything up and running, thanks to the_guv's brilliant guide.

Where I'm struggling and need help with are 301 redirects. I've got Wordpress running, with the proper permalinks, proper www vs non-www but I can't seem to figure out how to do a simple 301 redirect. Coming from using a wordpress plugin and apache .htaccess, I'm lost here.

Example: I'd to redirect

http://www.exampleurl.com/computer-syst ... pc/1500-2/

to

http://www.exampleurl.com/1500-htpc/

Here's what my /usr/local/nginx/sites-available/exampleurl.com file looks like:

Code:
server {

            listen   80;

            server_name  exampleurl.com;

            rewrite ^/(.*) http://www.exampleurl.com/$1 permanent;

       }

server {

            listen   80;

            server_name www.exampleurl.com;

            access_log /home/username/public_html/exampleurl.com/log/access.log;

            error_log /home/username/public_html/exampleurl.com/log/error.log;

            location /  {

                        root   /home/username/public_html/exampleurl.com/public/;

                        index  index.php index.html;

# Wordpress WP Super Cache plugin and permalinks.
include /usr/local/nginx/conf/wordpress_params.super_cache;

                        }

            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

            location ~ \.php$

                                {

            fastcgi_pass 127.0.0.1:9000;

            fastcgi_index index.php;

            include /usr/local/nginx/conf/fastcgi_params;

            fastcgi_param SCRIPT_FILENAME /home/username/public_html/exampleurl.com/public/$fastcgi_script_name;

                                }

      }


Basically, if you could show me an example of what code to insert and where to insert it, using the example above, I would greatly appreciate that. Thanks!


Top
   
 Post subject:
PostPosted: Tue Jul 13, 2010 4:46 pm 
Offline
Senior Newbie

Joined: Thu Feb 18, 2010 1:53 am
Posts: 10
From your info there is no generic way since nginx doesn't know what the URL turns into. It is not just a change of the URL but a completely different one. But if you have a certain set of hard ones to rewrite it would be something like
location = /computer-systems/home-theater-pc/1500-2/ {
rewrite ^ /1500-htpc/ permanent;
}

And just repeat for all your preexisting urls.

Syntax might be slightly off. Going off pure memory.


Top
   
 Post subject:
PostPosted: Tue Jul 13, 2010 10:39 pm 
Offline
Senior Newbie

Joined: Sun Jun 21, 2009 1:48 pm
Posts: 16
Website: http://www.hardware-revolution.com
WLM: gamecubemanrules@hotmail.com
Location: Montreal, Quebec, Canada
Schultz,

That's exactly what I was looking for and after testing it, I can confirm that it works perfectly.

Thanks a lot for your help and time.

Cheers,
Mathieu


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group