سؤال

I've searched and tried many of the examples listed on this site, but none seems to work right for me.

We have a running forum in /forum directory, which was previously named /vanilla2. Moving the forum (today) went ok and all internal links work fine. Redirecting the root of previous forum to the new one works ok using this:

RedirectMatch 301 /vanilla2/.* http://www.example.com/forum/

However the problem is because there are many posted links throughout the forum which still point to the old directory and its subdirectories, for example:
http://www.example.com/vanilla2/discussion/54684/blah-blah, which should now be:
http://www.example.com/forum/discussion/54684/blah-blah

Here's my directory structure:

/root
   .htaccess (for WordPress)
   /forum
      .htaccess (for forum)
   /wp
   /other_dirs and its subdirectories

My knowledge is obviously quite limited so I need to know what exactly to put in which of existing two htaccess files?

Thank you.

هل كانت مفيدة؟

المحلول

Put this code as first rule in your DOCUMENT_ROOT/.htaccess file ( a level above /forum/):

RewriteEngine On

RewriteRule ^vanilla2(/.*)?$ /forum$1 [L,NC,R=301]
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top