2
votes

nice people! :)

I have migrated a website (WordPress site) to another server. The wordpress install originally was in domain.com/site/, and it had an index file that redirected users to /site/. Now the WP install is in the root folder (domain.com/). I need to make that every request to domain.com/site/?p=x go to domain.com/?p=x I have been looking all over trying a lot of location rules, but I cant make it work. The best I could do is redirect from domain.com/site/?p=x to domain.com/site?p=x, and obviously that gives an 404.
The server in which the website was, was apache. Now in the new server I use nginx. I have used easyengine to install nginx, php-fpm, mysql. Created a wordpress site with w3tc plugin.

Can somebody help me? Thanks

1

1 Answers

2
votes

Great question!

Nginx is a good choice, do this in your nginx.conf:

location /site {
    rewrite ^/site/?((?<=/).*)?$    /$1 redirect;
    return  403;
}

The (?<= part is a lookbehind assertion, as per pcrepattern(3), which is from the pcre library that both Apache httpd as well as nginx use in support of the regular expressions.

The return 403; is necessary in case there is a security issue with the regular expression as written (e.g., if it fails to provide a redirect).