Click to See Complete Forum and Search --> : .htaccess redirect from old url to new?


CarolW
11-23-2005, 08:24 PM
When I started learning how to make my web site, I was using the free disk space that came with my email account on Islandnet. So the URL at that time was:

http://www.islandnet.com/~cwhitney/

Well, I had no idea that search engines were picking this up, and that URL seems to be very widespread. A few months later, I registered two domain names, and several months after that, a third.

But my Webalizer stats aren't showing in my logs as visits to my site, when access is via that old URL.

So I'm guessing that what I need to do to get more accurate Webalizer stats is to redirect from the old URL to at least one of the new ones, in which case I'd probably use coherentdog.org, which is mostly what I've been using (my other two are coherentdog.com and codog.org).

What would be the form of a line in my .htaccess file to accompilish a redirection from:

http://www.islandnet.com/~cwhitney/

to

http://coherentdog.org/

?

or, could be,

http://www.coherentdog.org/

Should I prefer one of the latter (coherentdog.org) over the other? What would my whole line look like?

GUESSING:


Redirect http://www.islandnet.com/~cwhitney/ http://www.coherentdog.org/


I have other redirects, all with relative addressing to start with, such as:


Redirect /layout.htm http://www.coherentdog.org/webinfo.htm


and those all seem to work fine.

Thanks in advance!

Wed, 23 Nov 2005 18:15:30

MstrBob
11-30-2005, 06:34 PM
Heylo.

You've got .htaccess? That's very good. Here's what you can put in it:


RewriteEngine on
RewriteRule (.*) http://www.coherentdog.org/$1


This has the advantage that any page the user goes to at the old domain, they will be sent to at the new domain. So say the went to

http://www.islandnet.com/~cwhitney/obydoby.htm

They would now get redirected to

http://www.coherentdog.org/obydoby.htm

Hope that helps some.

CarolW
11-30-2005, 09:56 PM
Heylo.

You've got .htaccess? That's very good. Here's what you can put in it:


RewriteEngine on
RewriteRule (.*) http://www.coherentdog.org/$1


This has the advantage that any page the user goes to at the old domain, they will be sent to at the new domain. So say the went to

http://www.islandnet.com/~cwhitney/obydoby.htm

They would now get redirected to

http://www.coherentdog.org/obydoby.htm

Hope that helps some.


Hey, MstrBob - you again to the rescue! So I just tried this. I think I'd better put up my code, because I'm not sure about just where to place the line. I placed it just before the anti-hot-linking-to-images line, so that portion of my .htaccess fille now looks like this:



RewriteEngine on
RewriteRule (.*) http://www.coherentdog.org/$1
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?coherentdog.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?coherentdog.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?codog.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?~cwhitney/.*$ [NC]
RewriteRule \.(gif|jpg|png)$ - [F]
Redirect /guestbook.htm http://www.coherentdog.org/kwaliguest.htm


Would there be a problem with the order of those lines in the file?

By the way, I also hold the domain names coherentdog.com and codog.org, and those point to the same location as coherentdog.org - would that require a change in the code in your example? Sending people to coherentdog.org is all I really care about, since that's the domain name I use most, and they all point to the same location anyway.

It'll be interesting to see my web stats. I have already put this file up on my site to replace the old one, so I hope it's okay, haha!

Too bad I don't understand the Webalizer stats very well, either! Hardly at all. I guess it will come with time!

Meantime, I just got more disk space for my site, which was getting very tight on space, so I can add more photos and articles. Love sharing my photos, and I"m a pig for article-space too.

I"m considering whether I can manage to put up one of my old hilarious error pages, because I thought those were very funny. WebDeveloper Forum people eventually saved me from my bottomliss-pit problems, and you and Fang were instrumental in this, but you are the one who got me through the borders-and-leaves effect I wanted to achieve. You people are amazing.

With endless thanks,

Wed, 30 Nov 2005 19:51:37

MstrBob
11-30-2005, 10:04 PM
Yep. At the top, that's where it would go. Looks good from here.

Glad to be of help.

CarolW
11-30-2005, 10:24 PM
Yep. At the top, that's where it would go. Looks good from here.

Glad to be of help.

Thanks! Lucky thing, since I already put the file up. Can you believe, it's only in the last few months I learned how to use FTP, and I was doing this whole thing with the infinitely slow File Manager on my ISP. Thank goodness for FTP.

I have another question, coming up, about an upload directory; will change to a new thread, since that's another topic.

Any reasonableness (workableness) on my site is thanks to WebDeveloper Forums and its denizens, and to W3C, and I thank you all profoundly.

Wed, 30 Nov 2005 20:22:42

CarolW
12-01-2005, 10:11 AM
Dear MstrBob and All who might help,

Heylo.

You've got .htaccess? That's very good. Here's what you can put in it:


RewriteEngine on
RewriteRule (.*) http://www.coherentdog.org/$1


This has the advantage that any page the user goes to at the old domain, they will be sent to at the new domain. So say the went to

http://www.islandnet.com/~cwhitney/obydoby.htm

They would now get redirected to

http://www.coherentdog.org/obydoby.htm

Hope that helps some.

Uh, Oh; this didn't work - or maybe it worked too well; I don't know! Anyway, it seems to have creamed CoDog (Coherent Dog). Hey, I should have CHECKED, first thing! But I didn't! And you didn't have my whole .htaccess file, so no way you could have looked to see if anything else was getting in the way of this proposed line.

Looks as though I put my new .htaccess file up with your suggested line in it about 19:37 last night. Just blithely went on my way, without checking. Shame on me! Then I did lots of stuff leisurely, ending with downloading Firefox 1.5 and installing it. After I had it installed, it took me to Google, and I went to Images, and looked for those from coherentdog.org - found most of them there, just not the background images. But then!

Then, I clicked on those to go to coherentdog.org, and - uh - I got this message:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@islandnet.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/1.3.34 Server at www.coherentdog.org Port 80

Yikes! So I tried going in directly from my machine, and again I got the same message. Uh, oh!

So I put my old .htaccess file back up, but that was something like 23:10, so my site was quite apparently down for a few hours, ouch!

Leaving out my denial of access to certain IPs, here's my .htaccess file - the one that had the new Rule in it to redirect from the username version at islandnet.com, "~cwhitney" to the coherentdog.org address. This is what it said when I uploaded it.

(The IP address denial just precedes this part, and there are also two other lines at the beginning of the file; I guess I'll leave those in, in case they apply.)


UseRealIP on
GeoIP on
<Limit GET POST>
order allow,deny
[list of denied IPs here]
allow from all
</Limit>
RewriteEngine on
RewriteRule (.*) http://www.coherentdog.org/$1 <== bad line here?
[the line above is the one I took out later]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?coherentdog.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?coherentdog.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?codog.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?~cwhitney/.*$ [NC]
RewriteRule \.(gif|jpg|png)$ - [F]
Redirect /guestbook.htm http://www.coherentdog.org/kwaliguest.htm
Redirect /guestbook3.htm http://www.coherentdog.org/kumbiguest.htm
Redirect /photosfront.htm http://www.coherentdog.org/photos.htm
Redirect /gbtwo.htm http://www.coherentdog.org/kumbiguest.htm
Redirect /prancydesk.htm http://www.coherentdog.org/z1prancydesk.htm
Redirect /kumbiinpen.htm http://www.coherentdog.org/z3kumbiinpen.htm
Redirect /wkubothpen.htm http://www.coherentdog.org/z4kwkubothpen.htm
Redirect /z1drerk.htm http://www.coherentdog.org/z1drerik.htm
Redirect /z6kwcarekulose.htm http://www.coherentdog.org/z6kwcarekuclose.htm
Redirect /collapse.htm http://www.coherentdog.org/gone.htm
Redirect /prancydesktest.htm http://www.coherentdog.org/gone.htm
Redirect /prancydesktest2.htm http://www.coherentdog.org/gone.htm
Redirect /blogmake.htm http://www.coherentdog.org/gone.htm
Redirect /blogdisplay.htm http://www.coherentdog.org/gone.htm
Redirect /blogmake2.htm http://www.coherentdog.org/gone.htm
Redirect /blogdisplay2.htm http://www.coherentdog.org/gone.htm
Redirect /blogmake3.htm http://www.coherentdog.org/gone.htm
Redirect /blogdisplay3.htm http://www.coherentdog.org/gone.htm
Redirect /bottomless.htm http://www.coherentdog.org/gone.htm
Redirect /carolbobeddie212.htm http://www.coherentdog.org/gone.htm
Redirect /carolbobeddie213.htm http://www.coherentdog.org/gone.htm
Redirect /disorient.htm http://www.coherentdog.org/gone.htm
Redirect /divel.htm http://www.coherentdog.org/gone.htm
Redirect /index19.htm http://www.coherentdog.org/gone.htm
Redirect /index131.htm http://www.coherentdog.org/gone.htm
Redirect /index142.htm http://www.coherentdog.org/gone.htm
Redirect /index146.htm http://www.coherentdog.org/gone.htm
Redirect /index159.htm http://www.coherentdog.org/gone.htm
Redirect /index189.htm http://www.coherentdog.org/gone.htm
Redirect /index7007.htm http://www.coherentdog.org/gone.htm
Redirect /index050414.htm http://www.coherentdog.org/gone.htm
Redirect /mstrbob201.htm http://www.coherentdog.org/gone.htm
Redirect /phototileback.htm http://www.coherentdog.org/gone.htm
Redirect /temp158.htm http://www.coherentdog.org/gone.htm
Redirect /temp159.htm http://www.coherentdog.org/gone.htm
Redirect /temp175.htm http://www.coherentdog.org/gone.htm
Redirect /template106.htm http://www.coherentdog.org/gone.htm
Redirect /template121.htm http://www.coherentdog.org/gone.htm
Redirect /template123.htm http://www.coherentdog.org/gone.htm
Redirect /template139.htm http://www.coherentdog.org/gone.htm
Redirect /template148.htm http://www.coherentdog.org/gone.htm
Redirect /template154.htm http://www.coherentdog.org/gone.htm
Redirect /template156.htm http://www.coherentdog.org/gone.htm
Redirect /template157.htm http://www.coherentdog.org/gone.htm
Redirect /test405d.htm http://www.coherentdog.org/gone.htm
Redirect /index050413.htm http://www.coherentdog.org/gone.htm
Redirect /layout.htm http://www.coherentdog.org/webinfo.htm
Redirect /test.html http://www.coherentdog.org/gone.htm
Redirect /test2.htm http://www.coherentdog.org/gone.htm
Redirect /tests.htm http://www.coherentdog.org/gone.htm
ErrorDocument 410 /gone.htm
ErrorDocument 404 /notfound.htm


What do you think? Something wrong there? I simply removed the new line and put the file back up as it had been before I added the line.

Thanks!

Thu, 01 Dec 2005 08:06:24

MstrBob
12-01-2005, 03:09 PM
Odd. Very odd. It's just the redirect line, you still have RewriteEngine on in your .htaccess? Perhaps try this, which is really the same thing:


RewriteRule ^(.*)$ http://www.coherentdog.org/$1 [R]


The fustrating thing about about .htaccess, is unless you have access to the server's error logs, you can't debug it. You just keep trying things until it works. If you're using this:


RewriteRule \.(gif|jpg|png)$ - [F]


Without an issue, than mod_rewrite is fine.

CarolW
12-02-2005, 07:28 AM
Odd. Very odd. It's just the redirect line, you still have RewriteEngine on in your .htaccess? Perhaps try this, which is really the same thing:


RewriteRule ^(.*)$ http://www.coherentdog.org/$1 [R]


The fustrating thing about about .htaccess, is unless you have access to the server's error logs, you can't debug it. You just keep trying things until it works. If you're using this:


RewriteRule \.(gif|jpg|png)$ - [F]


Without an issue, than mod_rewrite is fine.

I'll try this, when I have a bit of time unlikely to be interrupted too much! And of course, I'll report back! Thanks!

My web stats showed 53 Internal Server Errors for the approximate period I had the bad .htaccess file up. That'll teach me to check right away!

The difficulty with debugging is soemthing I've gradually become half-aware of; it's useful to know that!

Thanks again, MstrBob; you are the most incredibly helpful person!

Fri, 02 Dec 2005 05:27:46