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

special NGINX rewrite configuration

Discussion in 'Server Configuration and Hosting' started by Crazy-Achmet, Oct 8, 2013.

  1. Crazy-Achmet

    Crazy-Achmet Active Member

    Hey everybody,

    i need help with a special NGINX rewrite config. Right now, i'm using this configuration for my server.

    Ok, maybe it's a little complicated but i will try to explain.

    There is a physical folder called mydomain.de/test/test2 with a index.php inside of it. Now i would like to open mydomain.de/test/test2/this-is-just-a-test. Right now, all i got is a xenforo error, but since the folder /test/test2 exists, i would like the index.php to handle that request.

    Would it be possible, to deactivate the rewrite in that special folder? Or is there something else, i have to configure?

    It would be great if someone could help me with my problem. ;)

    Warm regards

  2. Crazy-Achmet

    Crazy-Achmet Active Member

    I wonder if @Jake Bunce didn't understand my question or if he doesn't know the answer! :unsure:

    Sorry about that, i just wanted to ask push again. ;)
  3. Tracy Perry

    Tracy Perry Well-Known Member

    Don't really think you need a rewrite for that... just a location definition added the the vhost setup if you have a index.php present in that directory.
    Or are you wanting it to mask the file and appear to be displaying "this-is-just-a-test" in the browser address bar.

    If so, then I think you still need to do a location definition for that directory and then rewrite the index.php to whatever you want it to be.
  4. Crazy-Achmet

    Crazy-Achmet Active Member

    I'm not really sure how it goes or what i need, as i'm a total new to NGINX. I thought it has to be a rewrite, but that could be totally wrong.

    Here is what i want to do: I have a lot (around 5.000) old URLs under /test/test2. The file /test/test2/index.php is handling the request and makes a redirect to the new URL in XenForo.

    If someone could tell me, what the location definition has to look lke, i would be more then happy. :)
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Add a new location for that base directory?

    location /test/test2/ {
    	try_files $uri $uri/ /test/test2/index.php?$uri&$args;
    	index index.php index.html;
  6. Crazy-Achmet

    Crazy-Achmet Active Member

    Know it's possible to open the index.php file, but if i try to access /test/test2/this-is-just-a-test/ all i got is a "404 not found - nginx"
  7. Tracy Perry

    Tracy Perry Well-Known Member

    You may need to add the
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME
        include /etc/nginx/fastcgi_params;
  8. Crazy-Achmet

    Crazy-Achmet Active Member

    Perfect, works like a charme know! Thank you both! ;)

Share This Page