Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
659 views
in Q2A Core by
I am trying to redirect old folders completely to the root of the q2a installation.

before I had on http://www.yourquestionplease.com an drupal installation used as qa site.

Now there are links in google like:

http://www.yourquestionplease.com/content/when-do-hurricanes-occur

This I want to redirect to

http://www.yourquestionplease.com

I added to the .htacces

the following redirect:

RedirectMatch 301 content/(.*) http://www.yourquestionplease.com/

but the result is a redirect to

http://www.yourquestionplease.com/?qa-rewrite=content/when-do-hurricanes-occur

there I have the ?qa-rewrite....  part, which I want to avoid to make it not double content for SE.

Does anybody know how to do that ?

1 Answer

0 votes
by

To redirect old folders to the main directory using a 301 redirect in your .htaccess file, you can use the following code snippet:

  1. RewriteEngine On
  2. RewriteRule ^old-folder/(.*)$ /$1 [R=301,L]

This code will redirect all requests from old-folder to the main directory. Make sure to replace old-folder with the actual name of your old folder. The (.*)$ is a regular expression that captures everything after old-folder/ and the $1 reuses that captured value in the redirection URL.

Remember to back up your .htaccess file before making changes, as incorrect configurations can cause issues with your website’s accessibility. If you’re not familiar with .htaccess syntax, it’s a good idea to consult with a web developer or a system administrator.

...