Bluesplayer Posted February 9, 2011 Report Share Posted February 9, 2011 Hi I am trying to redirect certain traffic to a new url. I made a mistake of moving menu sublinks to new parents, whereas I should have left the originals in place and created new ones. I am receiving traffic from google now to the old links which do not show the menu. The url I am trying to move is this one: index.php?case=subcategories&nc=39 The above is part of the url and not the complete url. I need to alter just this part to this: index.php?case=subcategories&nc=204 so that any visitors are sent to this new url instead. So far I have failed . RegardsBluesplayer Quote Link to comment Share on other sites More sharing options...
Bluesplayer Posted February 9, 2011 Author Report Share Posted February 9, 2011 I kinda fixed the above using javascript. I used this kind of code to redirect traffic: <script type = "text/javascript"> var thisURL = document.URL; thisURL = document.URL.toLowerCase(); if ((thisURL.indexOf("/electronics/tvs/index.php?case=subcategories&nc=33&nb=233")>-1)) { self.location='/electronics/tvs/index.php?case=subcategories&nc=204&nb=233'; }else{ } </script> I will alter it with each url that causes a problem. Ok another problem I have regarding htaccess - doh! I used a free domain name when I created my home server - ukproducts.hopto.org, but I have recently purchased a domain - ukproducts.co.uk. I now want to redirect all traffic to the new domain which normally I can do with a htaccess redirect such as this one: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !new domain name here/$ [NC] RewriteRule ^(.*)$ http://new domain name here/ [L,R=301] The above works perfectly when redirecting from a domain to a domain on different servers but doesn't work when used on a domain to redirect to the same domain on the same server. Why am I bothering to do this?Well the old domain has been indexed with google a lot whereas the new ain't. I want to redirect all old to new without losing the google indexing. Bit stumped on this one. Htaccess redirect or rewrite? Quote Link to comment Share on other sites More sharing options...
Michael D. Posted February 10, 2011 Report Share Posted February 10, 2011 I'm not terribly good with mod_rewrite myself, it'd be trial and error to get the right rules working. What I would do is use cPanel to set up a redirect and then look at the .htaccess and modify it as needed to make it work with the new domains/etc. Quote Link to comment Share on other sites More sharing options...
fshagan Posted February 11, 2011 Report Share Posted February 11, 2011 I would use a permanent redirect in .htaccess. Here's one I made to redirect a former page on one site to another site: Redirect 301 /GaffRig/ http://www.gaffrigpage.com/ The "/GaffRig/" is the old folder on the site, while the "http://www.gaffrigpage.com/" is the new site. To redirect a page on the same site, the syntax is the same: Redirect 301 /B&B/ http://messing-about.com/forums/index.php?/forum/8-b-b-yachts-forum/ In this case, I'm redirecting "http://messing-about.com/B&B/" to "http://messing-about.com/forums/index.php?/forum/8-b-b-yachts-forum/" on the same website. 301 redirects are one of the preferred methods according to Google. Quote Link to comment Share on other sites More sharing options...
Bluesplayer Posted February 18, 2011 Author Report Share Posted February 18, 2011 The redirects you posted do work but they are not for use when there are 2 or more domains and one or a few need to be parked. This works though: RewriteEngine on RewriteCond %{HTTP_HOST} ^parkeddomain.com$ [OR] RewriteCond %{HTTP_HOST} ^parkeddomain-2.com$ RewriteRule ^(.*)$ http://www.maindomain.com/$1 [R=301] Quote Link to comment Share on other sites More sharing options...
fshagan Posted February 19, 2011 Report Share Posted February 19, 2011 The redirects you posted do work but they are not for use when there are 2 or more domains and one or a few need to be parked. This works though: RewriteEngine on RewriteCond %{HTTP_HOST} ^parkeddomain.com$ [OR] RewriteCond %{HTTP_HOST} ^parkeddomain-2.com$ RewriteRule ^(.*)$ http://www.maindomain.com/$1 [R=301] Was that the ultimate solution? I don't know if the javascript method generates a permanent redirect that search engine bots see; if I'm reading your mod_rewrite directives correctly, you're using a permanent redirect that a bot would understand and index. Quote Link to comment Share on other sites More sharing options...
Bluesplayer Posted March 11, 2011 Author Report Share Posted March 11, 2011 Was that the ultimate solution? I don't know if the javascript method generates a permanent redirect that search engine bots see; if I'm reading your mod_rewrite directives correctly, you're using a permanent redirect that a bot would understand and index. After experimenting a bit more I have this solution in place for the cooking shop part of my site: RewriteCond %{HTTP_HOST} ^ukproducts4u.hopto.org$ [OR] RewriteCond %{HTTP_HOST} ^shops4u-online.co.uk$ RewriteRule ^(.*)$ http://ukproducts4u.co.uk/appliances/cooking/$1 [R=301] I hope Google will move the hopto.org indexed files and shops4u indexed files over to ukproducts4u now. I currently have 13 shopping scripts in place so I am going to alter the code above to suit each one - and also the root htaccess file too. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.