Forum Moderators: phranque

Message Too Old, No Replies

Port 80 Rewrite

         

Hissingsid

6:29 pm on Feb 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

I wonder if anyone here can offer some help or advice please.

Can I base a rewrite rule on a URL specifying :80 within it. There are some URLs in the Google index that are like this [domain.com:80...]

Can I use the :80 to rewrite only URLs containing that specifically in them?

Thanks for any help.

Best wishes

Sid

jdMorgan

6:44 pm on Feb 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sid,

I've never tried it, so I'm not sure that the "URL" as seen by RewriteRule or by RewriteCond %{REQUEST_URI} would contain the port number (I suspect it will not).

However, you may be able to test for the presence of a port specification using RewriteCond.

Something like:


RewriteCond %{HTTP_HOST} \:80$
RewriteRule <whatever you want to do here>

Please let us know if this works - It's a really good question.
(I'm not sure that the colon preceding the port number needs to be escaped - I just escaped it so as not to introduce a second problem)

Jim

bakedjake

6:59 pm on Feb 19, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Actually, I don't think that will work.

The browser (AFIAK) does not send the port number with the URI request.

I'm actually surprised that Google is displaying that - you'd think they'd strip of the :80. But, they're doing it because someone is linking to your site with it.

Sid: Maybe if you could describe a little more of what you want to do, we might be able to recommend a different solution.

Update: It does work in firefox, but not in Opera or IE.

jdMorgan

8:57 pm on Feb 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



bakedjake,
I can confirm your Firefox, IE, and Opera results. It's odd that IE 6.0 and Opera 7.23 feel free to drop the port number... I don't think they should do that. In addition to Firefox 0.8, Mozilla 1.6, Netscape 4.8, and Netscape 7.1 all work just fine.

Sid,
If the goal here is to get Googlebot to drop the port number from your listings in their index, I think the 301-redirect based on the {HTTP_HOST} method should work. If you want to redirect browsers, then it won't work for IE and Opera. :(

Jim