Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!

 



Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 

 



 

 www.CustomReportSharing.com 

From the folks who brought you High Rankings!



Photo
- - - - -

301 Redirecting From X Cart To Joomla


  • Please log in to reply
4 replies to this topic

#1 Galahad

Galahad

    HR 1

  • Members
  • Pip
  • 3 posts

Posted 30 January 2010 - 04:24 AM

Ok, let me first apologize for the possible length of this question but I'm now getting to the pulling hair out stage with this and it may take a while to explain thinking.gif

Originally I created an online shop using X Cart and now I have transferred over to joomla and virtuemart. My problem is that i get anything upwards of 500,000 hits to the website and don't particulary want to lose them with the links being no longer available in search engines.

The website provides merchandise for glamour models and so when you search for glamourmodelname mousemats, for example, you get a link to the appropriate mousemat category page which would look something like modelsupport.co.uk/modelshop/home.php?cat=90. I need to redirect this to modelsupport.co.uk/ms/index.php/glamourmodelname-mousemats/View-all-products.html

The domain name is the same in both cases. I've had a go at redirecting but my problem is that i get it to redirect but it adds the cat=90 information onto the end of the ...glamourmodelname-mousemats/View-all-products.html thus giving the visitor a 404 missing page

My other problem is the links to individual items. The link in the search engines may be modelsupport.co.uk/modelshop/product.php?productid=209&cat=90&page=1 which i would need redirecting to modelsupport.co.uk/ms/index.php/glamourmodelname-mousemats/View-all-products.html

I appreciate that this is a big task so, at this moment in time i would be happy if i could redirect modelsupport.co.uk/modelshop/ (and any link including that) to modelsupport.co.uk/ms/index.php/Glamour-Models/View-all-products.html and let them click on the link to the model required. So whether the link was modelsupport.co.uk/modelshop/product.php?productid=209&cat=90&page=1 or modelsupport.co.uk/modelshop/home.php?cat=90 they would still be redirected to modelsupport.co.uk/ms/index.php/Glamour-Models/View-all-products.html without it adding the cat=90 information on the end of the link

Is this possible

Thanks in advance for any help and apologies again for the length of the post

Galahad

#2 Ron Carnell

Ron Carnell

    HR 6

  • Moderator
  • 968 posts
  • Location:Michigan USA

Posted 30 January 2010 - 10:56 AM

QUOTE
I've had a go at redirecting but my problem is that i get it to redirect but it adds the cat=90 information onto the end ...

Sounds like you're almost there.

From the Apache docs: When you want to erase an existing query string, end the substitution string with just a question mark.

In other words, put a question mark at the end of your target URI and the query string will be stripped rather than automatically passed through. If necessary you can post an example of your mod_rewrite code, and I'm sure someone here can show you exactly where to add the question mark? But if you've gotten this far by yourself, you probably can figure it out. smile.gif




#3 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 30 January 2010 - 11:13 AM

It's not quite as bad or quite as rare as you may think Galahad.

Had to do the exact same kind of thing more than once myself. More than once when moving away from x-cart in fact! giggle.gif

See if I can guess right. Are you on a Linux/Unix based system that's running Apache with mod_rewrite installed and working? And are you using an .htaccess file to do the current redirects?

If so, the query string appending to the end of the new url is pretty easy. That's an automatic thing in Apache's rewrite module. The query string always gets added to the end if you don't specifically tell you want to drop it.

You drop the query string from the rewritten/redirect destination by putting a question mark (?) at the end of the new uri. So if your first stab at the redirect is getting to the correct base page name, you've got it basically whipped. You'll just need to add a question mark to the end of the rewrite uri string(s). Yeah, it's that simple. wink1.gif

As an example, let's say your rewriterule looked like:

CODE
RewriteRule $(.*)$ http://www.domain.co.uk/ms/index.php/glamourmodel-mousemats/View-all-products.html [R=301, L]


It would become the following with the additional question mark to stop the automatic query appending:

CODE
RewriteRule $(.*)$ http://www.domain.co.uk/ms/index.php/glamourmodel-mousemats/View-all-products.html? [R=301, L]


Looks strange perhaps, but that's how ya do it.

As to the second part of your question, you can use the same general idea to get that accomplished.

This would be the .htaccess way of getting it done. There are other scripted methods that may actually be better in certain circumstances. Namely using scripted redirects. I mention this not to confuse you, but because it should be.

What you have to remember when using the .htaccess at root redirects is that Apache has to parse through the entire .htaccess file for every single page/file hit made to the server to see if anything matches. So if you end up with a long .htaccess file it may end up adversely affecting both page load time and server CPU load. There are simply processes going on in the background that may not be necessary for all page hits, especially once people start going to the right places.

In the scripted method of redirects you allow yourself more flexibility in being able to apply regular expressions and logic to figure out which final destination uri needs to be applied to each old uri. And the biggest improvement comes from your having the ability to limit When It Fires to situations where the very specific old file is being accessed. For instance, for your Product page question above the scripted redirects for all of those pages would be put in a new file located at /modelshop/product.php, which would then handle all of the redirects.

Basically you can set up your matching -> redirecting logic either an array or a little case/switch routine to perform the matching. Then whatever pops out of that gets dynamically added to a single PHP Header scripted redirect. (Make sure to have a line in the scripted redirect to declare it a 301!)

This is a total replacement for an .htaccess type of redirect. It offsets a lot of the potential of server load issues, since it only fires when it needs to, when specific files have been accessed. And in some cases it gives you a lot better control over the logic behind your redirects.

Does that help?



#4 Galahad

Galahad

    HR 1

  • Members
  • Pip
  • 3 posts

Posted 31 January 2010 - 12:24 PM

hey guys, thanks for the quick and informative replies. As well as printing merchandise I make a living producing structural models of ships, planes, submarines and houses in various CAD packages but scripting is something I'm having to learn fast lol

I'll have a go later with your suggestions. Can't believe i may have just been missing a question mark!!

Thanks again guys, much appreciated

G

#5 Galahad

Galahad

    HR 1

  • Members
  • Pip
  • 3 posts

Posted 31 January 2010 - 12:27 PM

QUOTE(Randy @ Jan 30 2010, 04:13 PM) View Post
See if I can guess right. Are you on a Linux/Unix based system that's running Apache with mod_rewrite installed and working? And are you using an .htaccess file to do the current redirects?


Oh and yes Randy, you're spot on with your guesswork appl.gif





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

We are now a read-only forum.
 
No new posts or registrations allowed.