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

special NGINX rewrite configuration

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


Tracy Perry

Well-known 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. ;)
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.
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. :)

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;
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"

Tracy Perry

Well-known 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"
You may need to add the
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME
    include /etc/nginx/fastcgi_params;