Answered: How to redirect old folders to main through 301 htaccess

Post date: 2024-03-21 06:36:06
Views: 12

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.

Please click Here to read the full story.
 
Other Top and Latest Questions:
Here are Wednesday's biggest analyst calls: Tesla, Amazon, Airbnb, Domino's, Walmart, Disney & more
Alphabet tempers fears that it's falling behind in AI with blowout first-quarter results
Microsoft cloud growth accelerates on back of AI push
Jim Cramer's favorite investment themes in this rough market and 3 stocks he likes now
Elon Musk is keeping investors' dreams of a Tesla robotaxi alive
Mortgage demand drops as interest rates soar over 7%
Op-ed: Here are 6 health-care stocks to watch now, amid a bumpy recovery
Star Trek: Discovery: Mirrors
Special Event: Rifftrax: The Amazing Bulk
The Apothecary Diaries: The Unsettling Matter Of The Spirit