1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Nginx Rewrite Rules

Discussion in 'Server Configuration and Hosting' started by Chris D, Oct 12, 2012.

  1. Chris D

    Chris D XenForo Developer Staff Member

    Ok, thank you to everyone who suggested various hosts.

    Ultimately we decided upon Nimbus hosting who so far have been excellent.

    We now just need a little bit of help with setting up some nginx rewrite rules as previously we were using Apache, but these aren't as straight forward as normal rewrites.

    At the same time we moved from vBulletin 4 to XenForo, we also changed our domain name from Halflife2.net to Valvetime.net.

    We have two options:

    A - We simply get help with rewrite rules that redirect http://www.halflife2.net/forums/* to http://www.valvetime.net/* and we let the VB4 redirect scripts (showthread.php etc) do the rest which is effectively two redirects.

    B - We forget about the redirection scripts and we get help with all the rules necessary to redirect vB URLs to XenForo, e.g. http://www.halflife2.net/forums/showthread.php?t=12345 -> http://www.valvetime.net/threads/12345 etc.

    Cheers guys (y)
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Try this (option A):

    Code:
    location /forums/ {
    	if ($host ~* ^(www\.)?halflife2\.net$) {
    		rewrite ^(.*)$ http://www.valvetime.net/$1 permanent;
    	}
    }
    
     
    Chris D likes this.
  3. Arkshine

    Arkshine Active Member

    If I remember "if" in nginx is evil, what says the documentation. You can easily avoid it.
    Chris, mind to share you actual nginx site config ? It will be more easy to see what line to add is appropriate.
     
  4. Floren

    Floren Well-Known Member

    IF is evil, this is the proper way:
    Code:
    server {
    	listen		192.168.1.8:80;
    	server_name	halflife2.net *.halflife2.net;
    	rewrite ^	http://www.valvetime.net$request_uri? permanent;
    }
    Then you do the proper redirects on the new server configuration.
    You don't need the redirect script provided by XenForo devs, if you use nginx.

    Example:
    http://www.thcfarmer.com/forums/f9/
    http://www.thcfarmer.com/forums/f36/hi-all-28387/
     
    Chris D, bubbl3 and Ryan Mitchell like this.
  5. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    Nginx looks kinda complicated... :notworthy:
     
  6. Ryan Mitchell

    Ryan Mitchell Member

    It took me about a day to really start understanding the config format and how it works and figure out how I needed my config oriented. Once I did that, it was pretty simple, and I'm pretty confident about using it now. If you're not technically-oriented, Apache might be the better option for you - more information for setting it up and a larger community, I believe. That said, nginx is cool, and apparently the way to power larger boards. I like it.
     
  7. Mouth

    Mouth Well-Known Member

    Nope, much more efficient and easier to configure than Apache
     
  8. Ryan Mitchell

    Ryan Mitchell Member

    +1. Once you get it configured and you understand how the config structure works, it's MUCH easier to understand, keep track of, and modify. I really like it.
     
    Mouth likes this.
  9. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    I actually haven't played with it that much... is there any good reference available... I googled a lot but so far, no luck...
     

Share This Page