Move website, remove folder name from path

content-management.png

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.

About YellowWebMonkey

YellowWebMonkey Web design offers reliable website design, SEO and digital marketing services for Joomla, WordPress and Shopify sites. We strive to be a one-stop shop for all your web needs.

Recent Posts

Follow Us