homepage Welcome to WebmasterWorld Guest from 54.196.201.253
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
%09www. problem
I can't figure out how to redirect
Wally_Books




msg:1507907
 6:41 pm on Mar 26, 2006 (gmt 0)

Somehow Google has a prefix on the pages from our site of "%09", as in %09www.mysite.com. I have changed hosts and am trying write a redirect to www.mysite.com. Can some Help.

I had looked back and someone previously discussed a "%20" problem.

I have tried

RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

-and-

RewriteEngine on
RewriteCond %{HTTP_HOST} ^\%09www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

No success

 

jdMorgan




msg:1507908
 1:40 am on Mar 27, 2006 (gmt 0)

>No success

What do you mean?
How did you test?
What was the result?
How does that differ from your expectations?

Those basic questions/answers will help us help you.

The next thing to determine is whether a click on that malformed link will even reach your site. If so, then a solution can be found. If not, then you can try setting up wild-card DNS, and hope that "%09www" will be treated as a valid subdomain and passed to your server.

FYI, %09 is a Tab character, so it's likely the URL was found in or copied from a non-html document.

Jim

AlexK




msg:1507909
 2:15 am on Mar 27, 2006 (gmt 0)

I have a similar problem, although my desire is to prevent the URLs cluttering up the site LogWatch reports. Here are 3 identical access-log entries:

216.113.181.67 - - [25/Mar/2006:10:59:54 +0000] "GET /mfc/pb.html#MR2800 HTTP/1.0" 200 47473 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; .NET CLR 1.1.4322)" In:- Out:-:-pct.
216.113.181.67 - - [12/Mar/2006:10:49:07 +0000] "GET /mfc/pb.html#MR2800 HTTP/1.0" 200 47473 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; .NET CLR 1.1.4322)" In:- Out:-:-pct.
216.113.181.67 - - [14/Mar/2006:18:16:50 +0000] "GET /mfc/pb.html#MR2800 HTTP/1.0" 200 47473 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; .NET CLR 1.1.4322)" In:- Out:-:-pct.
(to prevent this board compressing them, I have replaced multiple spaces--tabs?--with a `')

httpd.conf for the relevant VirtualHost contains:
#
# redirect all non-``www.my-site.co.uk' requests
#
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.my-site\.co\.uk
RewriteRule ^/(.*) http://www.my-site.co.uk/$1 [L,R=permanent]

I would have expected the above to redirect requests preceded by a space/tab/white-space, but clearly not.

What is missing here?

moltar




msg:1507910
 2:19 am on Mar 27, 2006 (gmt 0)

Maybe the server is stripping the extra crap away before passing it to the mod_rewrite, but after it logs the request, which would actually make sense.

Try to do env variable dump and see what it displays. Does it display the malformed URL or the clean version?

You can do it easily with php - <?php phpinfo();?>

or in Perl

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print join '', map "$_ = $ENV{$_}<br>\n", keys %ENV;

jdMorgan




msg:1507911
 2:56 am on Mar 27, 2006 (gmt 0)

AlexK,

> I would have expected the above to redirect requests preceded by a space/tab/white-space, but clearly not.
> What is missing here?

Your domain redirect code won't affect your problem, because the tabs/spaces are not in your domain, they're in your URL-path. You can catch that kind of stuff by using %{THE_REQUEST} in a RewriteCond, and looking for one or more hex-encoded entities after the method (GET, POST, etc.) and before the first "/":

RewriteCond %{THE_REQUEST} ^[A-Z]+\ (\%[0-9a-f]{2})+/([^\ ]*)\ HTTP/
RewriteRule .* http://www.example.com/%2 [R=301,L]

Note that THE_REQUEST is the entire HTTP request header sent by the client, such as
GET /index.hmtl HTTP/1.0

If you wish to continue this discussion of bad URL-paths, let's do so in a separate thread, so as not to hijack discussion of Wally_Books (related-but-different) problem.

Thanks,
Jim

Wally_Books




msg:1507912
 3:34 am on Mar 27, 2006 (gmt 0)

>Jim
thanks for your response,

>What do you mean?

Google has 5000+pages from my site in the format
%09www.mysite.com/mypage.html

>How did you test?

My redirects? As in my example. I'm new to .htaccess so very likely was not doing something correctly.

>What was the result?

Didn't work, "could not be found"

>How does that differ from your expectations?

I recently changed hosts, and the previously host had a zeus server that could not do a 301 redirect. These links are pointing to my site, I was getting traffic from them at my previous host. According to my previous host: "Currently your site is set to redirect anything.mysite.com"

My current host is going to look into it but I'm not optimistic.

>The next thing to determine is whether a click on that malformed link will even reach your site.

They were being redirected at my previous host, I am trying to find out how, they do not have a phone# only email and a very slow to respond. Again they have a zeus server so their redirect may not apply to an apache.

>FYI, %09 is a Tab character, so it's likely the URL was found in or copied from a non-html document.

Yes, I've heard this,

Please let me know if there is any other information you might need to help me resolve this. I'm in supplemental h*ll as it is. I could use the little traffic this links were generating.

Wally

jdMorgan




msg:1507913
 4:01 am on Mar 27, 2006 (gmt 0)

This code should have worked, if any code is going to work:

RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

However, if you don't already have other working rewriterules, then you may need to add:

Options +FollowSymLinks

ahead of it, in order to enable mod_rewrite processing.

Jim

AlexK




msg:1507914
 6:21 pm on Mar 27, 2006 (gmt 0)

jdMorgan: Many apologies for highjacking the thread, and many thanks for the rewrite coding.

Also, because it applies with hindsight: doh!.

Wally_Books




msg:1507915
 1:26 pm on Apr 2, 2006 (gmt 0)

Needed the dns configuration corrected so that anything.yourdomainname is resolving to same ip as yourdomain or www.yourdomain.

Now redirect works. Thanks for the help.

I'm not sure what was done "server" side.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved