MDDHosting Forums: htaccess redirect - MDDHosting Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

htaccess redirect

#1 User is offline   Bluesplayer 

  • Member
  • PipPip
  • Group: Clients
  • Posts: 58
  • Joined: 20-March 10

Posted 09 February 2011 - 04:41 AM

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 :) .

Regards
Bluesplayer
0

#2 User is offline   Bluesplayer 

  • Member
  • PipPip
  • Group: Clients
  • Posts: 58
  • Joined: 20-March 10

Posted 09 February 2011 - 04:54 PM

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?
0

#3 User is offline   MikeDVB 

  • Forum Administrator
  • PipPipPipPipPip
  • Group: Staff Administrator
  • Posts: 1,545
  • Joined: 27-September 08
  • Gender:Male
  • Location:Central Indiana, USA

Posted 09 February 2011 - 08:38 PM

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.
Michael Denney - MDDHosting, LLC - Professional Hosting Solutions
LiteSpeed Powered - Shared, Reseller, Semi-Dedicated, and VPS
Incremental R1Soft CDP Backups on all shared, semi-dedicated, and VPS services!
http://www.mddhosting.com/ - Follow us on Twitter!
0

#4 User is offline   fshagan 

  • Member
  • PipPip
  • Group: Members
  • Posts: 139
  • Joined: 10-January 11

Posted 10 February 2011 - 08:18 PM

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.
0

#5 User is offline   Bluesplayer 

  • Member
  • PipPip
  • Group: Clients
  • Posts: 58
  • Joined: 20-March 10

Posted 18 February 2011 - 04:31 PM

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]

0

#6 User is offline   fshagan 

  • Member
  • PipPip
  • Group: Members
  • Posts: 139
  • Joined: 10-January 11

Posted 18 February 2011 - 08:34 PM

View PostBluesplayer, on 18 February 2011 - 04:31 PM, said:

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.
0

#7 User is offline   Bluesplayer 

  • Member
  • PipPip
  • Group: Clients
  • Posts: 58
  • Joined: 20-March 10

Posted 11 March 2011 - 04:26 PM

View Postfshagan, on 18 February 2011 - 08:34 PM, said:

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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users