Call Us: 512.271.5221

14
February
2013

Move website, remove folder name from path

This is how to re-direct existing URLs to the new path after moving the site. For example purposes, I am using /folder/, please substitute your own folder name (hey, there is always one person that doesn't).

SCENARIO: Client has a website in a subfolder on their server such as /folder/ so that the links currently indexed by google might be something like:

  • NON-SEF: http://www.example.com/folder/index.php?option=com_content&view=categories&id=3&Itemid=2
  • SEF1: http://www.example.com/folder/index.php/about-us
  • SEF2: http://www.example.com/folder/about-us.html
  • STRINGS: http://www.example.com/folder/?id=104

GOAL: When a user goes to those links, it automatically removes the /joomla/ but keeps the rest of the link intact. So the resulting link would be:

  • NON-SEF: http://www.example.com/index.php?option=com_content&view=categories&id=3&Itemid=2
  • SEF1: http://www.example.com/index.php/about-us
  • SEF2: http://www.example.com/about-us.html
  • STRINGS: http://www.example.com/index.php?id=104

 

STEPS: Follow these in order, and test after each step. If your problem is solved, you do not have to do rest of them.

1. If in a content management system, adjust the base url ONLY if you see the /folder/ in it.

a. WORDPRESS: in the wp-config.php, remove /folder/ from $baseurl = 'http://www.example.com';


b. JOOMLA: in configuration.php, remove /folder/ from var $live_site = 'http://www.example.com/folder';

c. DRUPAL: in 'sites/default/settings.php', remove /folder/ from $base_url = "http://www.example.com/folder";

 

2. In the .htaccess file, you would add this code or remove any existing /folder:

RewriteEngine On
RewriteEngine /

 

3. Add this code BELOW the previous step's code:

RewriteCond %{THE_REQUEST} ^GET\ /folder/(.*)
RewriteRule ^folder/(.*) http://www.example.com/index.php/$1 [L,R=301]

 

TESTING: The main reason we bother to adjust links is so any pages indexed by Google do not because broken links.  So the best way to test is to actually search for your index pages and then just click through them.  I will generally hold down the CTRL key while clicking through them so they open in new tabs.

Author: Alexis Priddy Categories: .htaccess

About the Author

Alexis Priddy

Alexis Priddy

Alexis moved to Waco in 2008 after five years in the United States Army as a military police officer.  Web design was a hobby that grew into a passionwhile she was in the military.  She is the founder of ArmyToolbag.com, a reference website for Army personnel that averages over 25,000 unique visitors a month.  When she sold that website to a national marketing firm, she decided to venture out and start YellowWebMonkey Web Design in 2009.  She has a Bachelor of Science degree in Psychology and Computer Science Engineering from the United States Military Academy at West Point, NY.

certified web designer

Get Started with YellowWebMonkey

Invalid Input

Invalid web address.

Invalid Input

Invalid Input

Joomla Certified Administrator