Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
  • Register
Welcome to the Q&A for Question2Answer.

If you have questions about the platform, click here to ask and please use English.

If you just want to try Q2A, please use the demo, which also grants admin access.

Apr 29: Q2A 1.5.2

Moving Q&A from root to subdirectory, help with 301 Redirect

+1 vote
I am having trouble figuring out how to configure my .htaccess file for a 301 redirect as I would like to move my Q and A script from the root to /qna/ subdirectory. However, the issue is I would also like to use the root directory for my website.

In summary how do I code or can I code some kind of 301 redirect in the .htaccess file such that I don't bugger up my existing indexed pages and at the same time free up the root so that I can install my website??? Can use a regex with RedirectMatch to accomplish this? If so, can someone please help me with the expression?

Thanks
asked May 1, 2011 in Q2A Core by anonymous

1 Answer

+1 vote

The question URLs are of the form /1234/question-title, so assuming you don't have pages on your main site that only consist of numbers, you can do something like:

RedirectMatch 301 ^/([0-9]+)/(.*)$ http://www.yoursite.com/qna/$1/$2

The other pages are probably not worth redirecting, but you can do the users and tags pages with this:

RedirectMatch 301 ^/user/(.*)$ http://www.yoursite.com/qna/user/$1
RedirectMatch 301 ^/tag/(.*)$ http://www.yoursite.com/qna/tag/$1

 

answered May 3, 2011 by DisgruntledGoat