Redirection problems with site re-organization

Using a single web hosting account to host multiple sites

Redirection problems with site re-organization

Postby LeeU » Mon Dec 18, 2006 2:06 pm

I'll try to make this as easy as I can. Up until recently, I had a Web site which used the address "http://www.shamar.org/emet/". Below that were a few directories. I recently obtained a domain name and set it up as an addon domain which pointed to that directory. I also set up a redirection in the .htaccess file for "shamar.org". I had thought that I could just put the following in the file and that would be enough:

Code: Select all
redirect 301 /emet http://www.emetnews.org


Well, for some reason, it wasn't, I had to add additional redirects (see below). Now, I am getting errors that leave out the directory I redirected to. For instance, I had a file with the path:

Code: Select all
http://www.shamar.org/emet/analysis/greatlie.php


Now, for some reason, I am getting errors that point to non-existent files at (and all the other sub-directories):

Code: Select all
http://www.shamar.org/analysis/greatlie.php



The code above should be redirecting it. Below is my .htaccess file. Any ideas of what is happening?

Code: Select all
redirect 301 /emet http://www.emetnews.org
redirect 301 /emet/analysis/ http://www.emetnews.org/analysis/
redirect 301 /emet/documents/ http://www.emetnews.org/documents/
redirect 301 /emet/views/ http://www.emetnews.org/views/

RewriteEngine on

RewriteRule ^current\.php$ http://www.emetnews.org/current.php
RewriteRule ^current\.htm$ http://www.emetnews.org/current.php

RewriteBase  /
RewriteRule   ^(.*)\.htm$              $1      [C,E=WasHTML:yes]
RewriteCond   %{REQUEST_FILENAME}.php -f
RewriteRule   ^(.*)$ $1.php                   [S=1,R]
RewriteCond   %{ENV:WasHTML}            ^yes$
RewriteRule   ^(.*)$ $1.htm

AddType text/html .html .htm

IndexIgnore *

RewriteRule ^weblog/?(.*)$ /cgi-bin/blosxom.cgi/$1

<Files .htaccess>
order allow,deny
deny from all
</Files>

AddHandler server-parsed .html .htm

ErrorDocument 400 /errorpage.php
ErrorDocument 401 /errorpage.php
ErrorDocument 403 /errorpage.php
ErrorDocument 404 /errorpage.php
ErrorDocument 500 /errorpage.php

<Files 403.shtml>
order allow,deny
allow from all
</Files>

<Files php.ini>
Order allow,deny
Deny from all
</Files>

# SetEnv TZ America/Miami
SetEnv TZ EST5EDT
LeeU
 
Posts: 8
Joined: Mon Dec 18, 2006 9:03 am

Postby richardk » Mon Dec 18, 2006 4:08 pm

You're getting 404 errors in your error log?

Try removing the redirects and using this:
Code: Select all
RewriteEngine On

RewriteRule ^emet(/(.*))?$       http://www.emetnews.org/$2          [R=301,L]
RewriteRule ^current\.(php|htm)$ http://www.emetnews.org/current.php [R=301,L]

RewriteCond %{REQUEST_URI} ^(/.+)\.htm$ [NC]
RewriteCond %{DOCUMENT_ROOT}%1.php -f
RewriteRule \.htm$ %1.php [R,L]

RewriteRule ^weblog(/.*)$ /cgi-bin/blosxom.cgi$1 [QSA,L]

You might want to make the 302 redirect ([R,L]) into a 301 redirect ([R=301,L]).
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby LeeU » Mon Dec 18, 2006 4:30 pm

It didn't work work and, in some cases, it didn't forward it. I added

Code: Select all
Options +FollowSymLinks


and my code (pertinent part) now looks like this:

Code: Select all
Options +FollowSymLinks
RewriteEngine on

redirect 301 /emet http://www.emetnews.org
RewriteRule ^current\.php$ http://www.emetnews.org/current.php
RewriteRule ^current\.htm$ http://www.emetnews.org/current.php

RewriteBase  /
RewriteRule   ^(.*)\.htm$              $1      [C,E=WasHTML:yes]
RewriteCond   %{REQUEST_FILENAME}.php -f
RewriteRule   ^(.*)$ $1.php                   [S=1,R]
RewriteCond   %{ENV:WasHTML}            ^yes$
RewriteRule   ^(.*)$ $1.htm

RewriteRule ^weblog/?(.*)$ /cgi-bin/blosxom.cgi/$1


However, I'm still getting 404's. just as before. The IP is generally from search engines (they have been hitting me hard the last few days).
LeeU
 
Posts: 8
Joined: Mon Dec 18, 2006 9:03 am

Postby richardk » Tue Dec 19, 2006 9:26 am

So it's not the Redirects that are wrong, it's just that there are some incorrect links that bots are following. Or do you logs show that the redirects are redirecting to the wrong place?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^(www\.)?shamar\.org$ [NC]
RewriteCond %{DOCUMENT_ROOT}/emet{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/emet{REQUEST_URI} -d
RewriteRule ^(.*)$ http://www.emetnews.org/$1 [R=301,L]

RewriteRule ^emet(/(.*))?$       http://www.emetnews.org/$2          [R=301,L]
RewriteRule ^current\.(php|htm)$ http://www.emetnews.org/current.php [R=301,L]

RewriteCond %{REQUEST_URI} ^(/.+\.)htm$ [NC]
RewriteCond %{DOCUMENT_ROOT}%1php -f
RewriteRule \.htm$ %1php [R,L]

RewriteRule ^weblog(/.*)?$ /cgi-bin/blosxom.cgi$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby LeeU » Tue Dec 19, 2006 10:18 am

The redirects seem to work fine when the address is as stated in the .htaccess file. However, I am getting errors that are eliminating the "/emet/" directory, which, of course, do not redirect and cause an error. For instance, entering the URL: "http://shamar.org/emet/analysis/the_true_leaders.php" redirects to "http://www.emetnews.org/analysis/the_true_leaders.php", as it should. However, I am getting errors that give the following directory (notice that the "/emet" portion is missing): "http://shamar.org/analysis/the_true_leaders.php".

I have no idea where this is coming from. It doesn't seem to make sense. I have never used that URL. I have checked my sitemap files that I recently updated (that Goggle/Yahoo use) and they're not in there either.

BTW, I haven't tried the last code you gave me yet. Do you think it will make a difference in regards to this problem?
LeeU
 
Posts: 8
Joined: Mon Dec 18, 2006 9:03 am

Postby richardk » Tue Dec 19, 2006 10:33 am

BTW, I haven't tried the last code you gave me yet. Do you think it will make a difference in regards to this problem?

Yes, the first (big) rule should redirect it to the right place. If the requested URL doesn't exist, but it does exist in the /emet directory it will redirect to the emet domain.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby LeeU » Tue Dec 19, 2006 10:47 am

O.k., I'll upload it and see what happens. Thanks.
LeeU
 
Posts: 8
Joined: Mon Dec 18, 2006 9:03 am

Postby LeeU » Tue Dec 19, 2006 10:51 am

Ooops. Well, I loaded it and it won't redirect to the emetnews.org domain when the following is entered:
Code: Select all
http://www.shamar.org/emet/


(I reloaded the previous one for now.) Any suggestions?
LeeU
 
Posts: 8
Joined: Mon Dec 18, 2006 9:03 am

Postby richardk » Tue Dec 19, 2006 11:14 am

Just that URL?

It should:
Code: Select all
RewriteRule ^emet(/(.*))?$ http://www.emetnews.org/$2 [R=301,L]


You could try adding the Redirect to it. Or
Code: Select all
Options +FollowSymLinks
RewriteEngine on

redirect 301 /emet http://www.emetnews.org
RewriteRule ^current\.php$ http://www.emetnews.org/current.php
RewriteRule ^current\.htm$ http://www.emetnews.org/current.php

RewriteBase  /

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^(www\.)?shamar\.org$ [NC]
RewriteCond %{DOCUMENT_ROOT}/emet{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/emet{REQUEST_URI} -d
RewriteRule ^(.*)$ http://www.emetnews.org/$1 [R=301,L]

RewriteRule   ^(.*)\.htm$              $1      [C,E=WasHTML:yes]
RewriteCond   %{REQUEST_FILENAME}.php -f
RewriteRule   ^(.*)$ $1.php                   [S=1,R]
RewriteCond   %{ENV:WasHTML}            ^yes$
RewriteRule   ^(.*)$ $1.htm

RewriteRule ^weblog/?(.*)$ /cgi-bin/blosxom.cgi/$1
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby LeeU » Tue Dec 19, 2006 11:32 am

For some reason, either yours or mine, if I use the URL: "http://www.shamar.org/emet/index.htm", it goes to "http://www.shamar.org/index.php", completely removing the "/emet" directory in the link.

However, if I leave off the file name, i.e. "http://www.shamar.org/emet/", it does redirect.
LeeU
 
Posts: 8
Joined: Mon Dec 18, 2006 9:03 am

Next

Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 103 guests

cron