Jump to content
MDDHosting Forums

htaccess redirect


Bluesplayer

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 3 weeks later...

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...