Migrated website needs a redirect WordPress


Hello there, great community! :slight_smile:

I have recently migrated a website from one server to another, keeping the same domain. The website used to work with domain.com**/site/**, where the site folder was were the wordpress install was. The site used to have the default WP permalinks structure (?p=x)

Now, I did an ee wp install with w3tc plugin, and I use this permalink structure: /%category%/%post_id%/%postname%

What I need to do is to redirect any user that goes to domain.com/site/?p=x to domain.com/?p=x

I know it shouldn’t be difficult, it surely needs to be a single location rule, but somehow I can’t make it work.

Can somebody please help me? Thank you very much!

location /site {
    rewrite ^/site/(.*) /$1 permanent;

Put the code above in a file named something.conf (I’d use redirect.conf) in /var/www/domain.com/conf/nginx/ and restart (or reload) Nginx:

service nginx reload

That should solve your immediate problem. Perhaps not the best way to achieve your goal, but consider it a starting point.


Thank you! :slight_smile: