Search

Please Subscribe

Like it? Share it!

Add to: JBookmarks Add to: Facebook Add to: Mr. Wong Add to: Buzka Add to: Windows Live Add to: Icio Add to: Digg Add to: Del.icoi.us Add to: Reddit Add to: Jumptags Add to: Upchuckr Add to: StumbleUpon Add to: Slashdot Add to: Netscape Add to: Furl Add to: Yahoo Add to: Diigo Add to: Technorati Add to: Newsvine Add to: Folkd Add to: Google

Get Your Gear at Amazon

Sponsors

HostMonster.com
HostMonster! Reliable and Affordable Web Hosting!
BlueHost.com
BlueHost, A Great Web Hosting solution.
Amazon.com - Hot Deals
Amazon.com! Check out computer related hot deals!
Get Clicky - Web Analytics
Cool Web Analytics Tool! Give it a try and let me know what you think
Upgrade Memory
Upgrade Your Ram! Simple tools to help find the correct memory stick at a great price.
Home Web Development SEO How To Redirect Old Joomla or Mambo Dynamic URLs with htaccess
How To Redirect Old Joomla or Mambo Dynamic URLs with htaccess E-mail

When this site was redesigned I had an issue with trying to get my old URLs to point at the new URL. I didn't want to lose rank in the search engine or have any broken links to this site.

When you run on an apache web server there is a file called .htaccess that is located in the root directory of your site. This file is read by the web server before the page is called. If a redirect is in place for the URL that was requested will call the new URL. If there is no redirect in place it will just call the page that was requested.

This is usually a pretty simple thing to do however there are a few extra things you have to do with a dynamic URL. You will have to escape some of the special characters as well as deal with the query string that is called in the URL. So for example the way this website use to call a specific webpage was by http://mixeduperic.com/index.php and then a query string after that. So it would look something like this for one single page.

http://mixeduperic.com/index.php?option=com_content&task=view&id=71&Itemid=52

The problem I ran into was how to deal with query string (anything after index.php?) and redirecting to the new page. I searched all over the web trying to find an example on how to do this. After reading through apache’s website for a while I managed to figure out a solution. This is how I did it.


Example: I want to be able to redirect
Old URL: http://mixeduperic.com/index.php?option=com_content&task=view&id=71&Itemid=52
To
New URL: http://mixeduperic.com/Linux/Networking/test.html

 


This is the code I used to do the redirect the dynamic URLS.

RewriteCond %{REQUEST_URI} /index\.php
RewriteCond %{QUERY_STRING} option=com_content&task=view&id=71&Itemid=52
RewriteRule ^(.*)$ http://mixeduperic.com/Linux/Networking/test.html? [L,R=301]

This worked out very slick. The users would never know they where being redirected other then the URL changed.

 

If you want to pass the query string to the new URL you could just take off the ‘?” at the end of the new URL.

So for example if I wanted the http://mixeduperic.com/index.php?option=com_content&task=view&id=71&Itemid=52 to go to http://newwebsitename.com/option=com_content&task=view&id=71&Itemid=52 Put this code in my htaccess file.



RewriteCond %{REQUEST_URI} /index\.php
RewriteCond %{QUERY_STRING} option=com_content&task=view&id=71&Itemid=52
RewriteRule ^(.*)$ http://newsitename.com/ [L,R=301]


Notice on the last line, the question mark is missing after the new URL. The question mark is basically saying this is the end of the URL.

You will need to put that bit of code in you .htaccess file for every URL that you want to redirect.

 

I hope you found this information useful. 

Please give us some feedback, let us know your thoughts about "How To Redirect Old Joomla or Mambo Dynamic URLs with htaccess"!

Bookmark with:

Deli.cio.us    Digg    reddit    Facebook    StumbleUpon    Newsvine
 


Another articles:


mixedperic.com
Feedback Form