Weblogic Joomla Template Demo

JoomlaChicago Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Re:301 Redirects in HTACCESS explained! (1 viewing) (1) Guest
Programs and tips from beginner to becoming a Joomla! Blackbelt.
Go to bottom Post Reply Favoured: 0
TOPIC: Re:301 Redirects in HTACCESS explained!
#823
Nick Martinelli (Admin)
Admin
Posts: 46
graphgraph
User Offline Click here to see the profile of this user
301 Redirects in HTACCESS explained! 7 Months ago  
After spending hours researching and repeated trail and error I would like to share how to setup 301 redirects in your .htaccess file.

I have two examples to share.

1) Redirecting a static ASP page name
2) Redirecting a ASP query string

What am I'm redirecting to? New joomla pages!

1) How to perform static redirects:

Code:


# Code below redirects my old site's homepage to the new homepage.
redirect 301 /index.asp http://www.mysite.com/
redirect 301 /index.asp http://www.mysite.com/

# Code below redirects a static ASP,html page to a new joomla url
redirect 301 /content/aboutus.asp http://www.mysite.com/index.php?option=com_content&task=view&id=2&Itemid=7
redirect 301 /content/somepage.html http://www.mysite.com/index.php?option=com_content&task=view&id=2&Itemid=7



2) How to perform ASP query string redirects.
Code below redirects my old shopping cart url to my new url. Note, I had to put in the ARTIO SEF URL and not the full joomla query string. Artio SEF wouldn't pick up the url and translate it into a sef url. So I had to do it the long way. Thankfully I was able to use excel to create list of all my url conversions using a formula.

Code:


RewriteCond %{QUERY_STRING} ^id=2$
RewriteRule ^cart/shopexd.asp$ http://www.mysite.com/products/business/state-business-titles/partnership-in-florida.html$1? [R=301,L]




Example 2 code explained. In line 1 I have "^id=2$." "^" is the start of string indicator, and "$" is the end of string indicator. This tells the server request that this is the query string to look for in the url. In line two, "^cart/shopexd.asp$" tells it what page, to be looking for. The next code is the url to redirect to. Notice the ""$!?" this tells the request to remove everything after the ? in the url that the page is loading.

Hope this helps, this was a huge roadblock for me to get passed. We ported from ASP and IIS to Joomla and Apache. I'm getting ready to convert our company's main site in May and I have 1000+ urls to redirect so we don't lose any traffic. This is crucial if your porting over to a different web platform. I highly recommend doing when you move pages around. Now if you are redirecting from within joomla you can use sh404SEF or Artio's SEF components. I like Artio's application slightly better because it doesn't always require custom sef plugins for most components and modules. Its pretty good about picking them up on its own. But sh404SEF have some visible security options enabled. I'm still haven't decided on one to go with as I use both. So try them out for yourself and see which one works best for your business needs. I'm super picky about urls so I do heavy customizing.

Feel free to ask any questions about the code I posted. I'm very excited to share this with everyone it was a major hurdle to overcome.

I also attached a htaccess cheat sheet I got from www.ILoveJackDaniels.com. This cheatsheet explains code that can be used when using Mod Rewrite in the .htaccess file.

File Attachment:
File Name: mod_rewrite_cheat_sheet.pdf
File Size: 332133


P.S. I'll make sure I mention this in my talk at next month's meeting, showcasing my VirtueMart e-commerce site.
 
Report to moderator   Logged Logged  
 
Last Edit: 2008/04/25 10:54 By shreddemon.
  The administrator has disabled public write access.
#838
John Coonen (Admin)
Admin
Posts: 375
graph
User Online Now Click here to see the profile of this user
Gender: Male The Coffee Group CoffeeGroupUSA Location: Crystal Lake, IL Birthdate: 1964-07-03
Re:301 Redirects in HTACCESS explained! 6 Months, 3 Weeks ago  
Excellent Nick!
 
Report to moderator   Logged Logged  
 
John Coonen
Chief Bottlewasher - CMS Association www.CMSAssociation.com & www.CMSExpo.net
  The administrator has disabled public write access.
#867
Nick Martinelli (Admin)
Admin
Posts: 46
graphgraph
User Offline Click here to see the profile of this user
Re:301 Redirects in HTACCESS explained! 6 Months, 3 Weeks ago  
Soon as I got these in my site traffic jumped right up.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop