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

Permanent 301 Redirect


  • This topic is locked This topic is locked
320 replies to this topic

#256 paullatta

paullatta

    HR 1

  • Members
  • Pip
  • 2 posts

Posted 21 April 2006 - 09:13 PM

OK, I searched through this whole thread and can't find the answer I need.

I am changing web hosts for my e-commerce site from Webii to Monster Commerce. I will keep the same domain name. Rank well with old pages. I want to keep my old site up and running for a couple of months until google finds the new pages (total redesigns, files, names, etc.). I want to use a 301 redirect to get any hits to the new pages. I.e. someone clicks on the widget.htm page I want to get them to the new page on the new host. I used Frontpage to create and publish the old site. I do not have access to a .htaccess file and I am not able to create one either. I'm not sure what type of server I am on. I'm using Softcart as my shopping cart, but the site is a two part site. Main domain is a brochure site, the store is in a sub-domain.

I have a meta refresh solution that works, but I really want to do a 301 redirect because of my rankings.

Is there some code I can place on each page to perform the redirects? The issue is Frontpage. I've heard that even if you have access to your .htaccess file it causes loops. Any help would be appreciated.

Thanks ! Paul

#257 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 22 April 2006 - 08:14 AM

Hey Paul,

You'll definitely want to figure out what type of server your site is running on. It's a pretty critical piece of information.

Can you set up individual page redirects? Sure you can. That's the good news.

Did the old pages have a .htm or .html extension? Or were they .asp or .php? If they were the latter it'll be pretty easy to do, though a bit time consuming on a one-time basis. If the old pages were .htm or .html you'll need to have the new host configure the server so that .htm and/or .html files can be pre-processed by either ASP or PHP.

Chris posted some code about halfway down the first page of this long thread showing how to do individual page redirects with both php and asp. That's what you would use in each page.

So, if the old pages carried either a .php or .asp extension you're good to go with just that individual page redirect code.

If the old pages were .htm or .html it'll be a two-step process. First get the server configured so that it'll pre-process the extension(s) you used by either ASP or PHP, then upload you individual redirect pages.

#258 RippleSpas

RippleSpas

    HR 1

  • Members
  • Pip
  • 1 posts

Posted 10 June 2006 - 05:04 AM

What a useful thread, I am feeling much more knowledgeable than when I started clapping.gif

However.....

I have 10 domains that are an alias of the main domain and hence use that domains content. I want them to redirect to the main domain as reccommend.

When I use the code in the .htaccess file in the root of the main domain, I get an internal server on all domains, including the main domain:

CODE
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} !^domain\.co.uk
RewriteRule ^(.*) http://www.domain.co.uk/$1 [L,R=301]


I have TRIED to explain to my provider what I wish to acheive and they have said this is not possible cry.gif, but I am not sure I am getting to the right level of support. I read earlier in the thread something about mod_alias support, is this what my alias domains need in order to work?

RippleSpas

#259 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 10 June 2006 - 06:34 AM

Welcome RippleSpas ! hi.gif

You're missing a backslask to escape one of the periods in your RewriteCond statement. That would cause the error since dots have a special meaning in Regex. You're also not really catching all of the potential www/non-www traffic.

Here's what I would use:

CODE
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.co\.uk
RewriteRule ^(.*) http://www.domain.co.uk/$1 [L,R=301]


#260 MichaelM

MichaelM

    HR 4

  • Active Members
  • PipPipPipPip
  • 109 posts
  • Location:Belfast, Northern Ireland

Posted 31 July 2006 - 02:26 PM

Hey,

Ive read this thread, and can see that its directed mainly to www/non-www problems, but can it be used for a normal redirect? I want to skip past the page I previously used as a splash page.

If my domain was "http://www.domain.com" I want that to automatically redirect to "http://subdomain.domain.com"

Im new to all of this, and have no proper experience in actual programming/coding really, so Im getting lost sad.gif

There seems to be alot of options, so does anyone know what would be best for what I want to do? Can anyone help? sad.gif

#261 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 31 July 2006 - 02:40 PM

Welcome MichaelM ! hi.gif

As you've probably noticed, redirecting becomes a pretty individualized thing, depending upon your exact situation and what you're trying to cure.

Do all of your pages now reside on the subdomain.yoursite.com address? Or do you need to simply redirect a single page to this subdomain?

As an aside, why the move to a subdomain if everything is moving? Hopefully it's for solid visitor-centric reasons. Because if you move your whole site there is going to be some time where you're going to lose rankings and traffic.

#262 MichaelM

MichaelM

    HR 4

  • Active Members
  • PipPipPipPip
  • 109 posts
  • Location:Belfast, Northern Ireland

Posted 31 July 2006 - 02:50 PM

Hey Randy, thanks for replying to my message!

Yes, Ive noticed that this seems quite an individual issue, so I will explain my website as best as I can.

My entire website is on the subdomain (And it always has been), so the URLs arent actually changing. Up until now, the only thing on the main domain was a single index.html, which acted as a splash page to get to my actual site, which was on the subdomain.

I now realise that splash pages are simply an annoyance, and would like to remove the splash altogether. Unfortunately, I cannot move the whole site to the main domain, as that would break every link I have ever had. sad.gif

I want a way to move my visitors from http:/ /www.domain.com (And http:/ /domain.com) directly to http:/ /subdomain.domain.com, and I would like the URL in the URL bar to change as well to show the change, if possible? (So that they can easily bookmark, copy the link?)

Is that possible? I know of a meta-refresh way, but I also know its very bad with search engines, so I don't want to use that. sad.gif

Thanks!

[Edited to break inadvertant links. ~Randy]

Edited by Randy, 31 July 2006 - 08:28 PM.


#263 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 31 July 2006 - 08:26 PM

Sure there's a way. It's actually an easy one, assuming your host has mod_rewrite enabled for you to make use of.

CODE
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^subdomain\.domain\.com
RewriteRule ^(.*)$ http://subdomain.domain.com/$1 [R=301,L]


What the above does is look at the HTTP_HOST --or URL address-- being queried when any page is requested from the server. The rewrite condition says [i]If the URL being requested begins with anything other than the subdomain.domain.com, the traffic should be automatically and permanently redirected to the subdomain address.

If you have a typical subdomain setup where the files actually reside at the location for the main domain the above would be placed at the root level of your web space. If the subdomain files happen to be stored at a different path than your normal www files are, then you can slap the above at the root level of your normal www space.

#264 MichaelM

MichaelM

    HR 4

  • Active Members
  • PipPipPipPip
  • 109 posts
  • Location:Belfast, Northern Ireland

Posted 01 August 2006 - 06:19 AM

Thank you so much! That was fantastic! It works a charm smile.gif

Can I ask you another question? I assume this means that if I was to set up another subdomain, then it would also redirect that subdomain to the main subdomain? Or does this only apply to people trying to request the main domain?

If it does apply to the subdomains as well, is there a way I could avoid this?

The reason Im asking is because in the near future, I plan on offering free hosting to similar, smaller sites, so I will need the use of my subdomains for that smile.gif

And thanks again! For the speedy reply, and the perfect solution! biggrin.gif

Edited by MichaelM, 01 August 2006 - 07:08 AM.


#265 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 01 August 2006 - 11:05 AM

The above would refer everything over to your main subdomain. So you wouldn't want to use it with multiple subs. But that doesn't mean what you're looking for can't be done. In fact, I'm 100% positive that it can be done since mod_rewrite is so darned flexible.

It's not something I've done before, so let me set up a little test if nobody else comes by with a solution. Off the top of my head, I think it'll take a couple of RewriteCond statements, one for www/non-www and one for the rest of the subs. But still it'll end up being fully dynamic so that you won't need to change anything as new subs are added.

#266 MichaelM

MichaelM

    HR 4

  • Active Members
  • PipPipPipPip
  • 109 posts
  • Location:Belfast, Northern Ireland

Posted 02 August 2006 - 05:51 AM

Thanks! smile.gif

Im sure you've thought of this already, but still, would there be a way to change the Rewrite Condition part, so that only URLs beginning with "http://domain.com" and "http://www.domain.com" are effected, instead of the sort of "If else..." rule you originally suggested?

There isnt actually anything on the www.domain.com level, and never has been. Just one index page, that had nothing more than a link to the subdomain, so really, there wouldnt be any people linking to specific pages on that domain. (Im not sure if that helps, but Im just mentioning everything, incase it simplifies things at all. xD )

Thanks again for going to all this trouble! I really appreciate it! biggrin.gif

#267 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 02 August 2006 - 07:01 AM

Let me back up a little bit Michael, because I'm not sure I'm fully grasping what you want to happen.

Is it as simple as this?

1. You want any traffic going to domain.com or www.domain.com to be redirected to subdomain.domain.com.
2. You want to leave everything else alone, meaning you don't need any further redirection for any subdomain?

If that's what you're going after, yes it's very easy to do by simply detecting domain.com (no www. or any other sub) and the www. sub. The following should do the trick.

CODE
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com [NC]
RewriteRule ^(.*)$ http://subdomain.domain.com/$1 [R=301,L]


The (www\.)? bit of regex will match both www.domain.com and domain.com, but will not match subdomain.domain.com, sub2.domain.com, etc.

Is this what you're looking for?

#268 MichaelM

MichaelM

    HR 4

  • Active Members
  • PipPipPipPip
  • 109 posts
  • Location:Belfast, Northern Ireland

Posted 02 August 2006 - 07:07 AM

Yes! Thats exactly what I wanted! Im sorry if I explained it very badly earlier! sad.gif

Ive put the new code in place, and it is running absolutely perfectly! Thank you so so so much!

And sorry for putting you to all this trouble! sad.gif

#269 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 02 August 2006 - 07:14 AM

No trouble at all. I just mis-read it originally.

That's always the deal with redirecting/rewriting. It's so powerful and flexible that pretty much anything can be done with a bit of regex. But sometimes it's difficult to get there because each situation is so specific. It's tough to generalize when dealing with such an exacting science.

#270 MichaelM

MichaelM

    HR 4

  • Active Members
  • PipPipPipPip
  • 109 posts
  • Location:Belfast, Northern Ireland

Posted 02 August 2006 - 08:32 AM

lol, Its definitely very flexible though if it can suit so many people! biggrin.gif

Im sorry to bother you again though, but I have one more question. sad.gif

Right now, alot of my links go to "http://www.domain.co.../subdomain/..." and with the rewriting, the link are being changed to "http://subdomain.dom.../subdomain/..." which doesnt exist.

I can fix the very vast majority of those, but my site search engine automatically uses this form of link, instead of the proper, "http://subdomain.domain.com/..." links, and I have no way to change this. sad.gif

Is there a way to make it so that only people loading the exact URLs, "http://www.domain.com" and "http://domain.com" are redirected?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

SPAM FREE FORUM!
 
If you are just registering to spam,
don't bother. You will be wasting your
time as your spam will never see the
light of day!