MDDHosting Forums: htaccess redirect - MDDHosting Forums
Page 1 of 1
htaccess redirect
#1
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:
The above is part of the url and not the complete url. I need to alter just this part to this:
so that any visitors are sent to this new url instead.
So far I have failed
.
Regards
Bluesplayer
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
#2
Posted 09 February 2011 - 04:54 PM
I kinda fixed the above using javascript. I used this kind of code to redirect traffic:
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:
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?
<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?
#3
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!
█ 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!
#4
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:
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:
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.
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.
#5
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]
#6
Posted 18 February 2011 - 08:34 PM
Bluesplayer, 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.
#7
Posted 11 March 2011 - 04:26 PM
fshagan, 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.
Share this topic:
Page 1 of 1

Help












