Gossamer Forum
Home : General : Perl Programming :

Rewrite

Quote Reply
Rewrite
Im having a bit of touble with a rewrite rule and can't see why it doesn't work.

I just double checked and my REMOTE_HOST ends with ntli.net so I want to redirect that host to another URL so I tried:

RewriteEngine On
RewriteCond %{REMOTE_HOST} ntli\.net$
RewriteRule ^.* http://www.wiredon.net/img/ [R,L]

This doesn't do anything.

However:

RewriteEngine On
RewriteCond %{REMOTE_HOST} ^$
RewriteRule ^.* http://www.wiredon.net/img/ [R,L]

...does.

BUT it seems to get stuck in a loop and never loads the /img/ url properly.

Anyone have any ideas why this is? ......rewriting to a different URL works ok.

Also does anyone know why it isn't detecting my host properly? ......Ive tried loads of different things like HTTP_USER_AGENT and they seem to work ok, it just doesn't seems to recognise my REMOTE_HOST

Last edited by:

RedRum: Oct 31, 2001, 5:47 PM
Quote Reply
Re: [RedRum] Rewrite In reply to
Have you got HostNameLookups On?

- wil
Post deleted by yogi In reply to
Post deleted by RedRum In reply to

Last edited by:

RedRum: Nov 1, 2001, 3:29 AM
Quote Reply
Re: [Wil] Rewrite In reply to
Yes, still doesn't work.
Quote Reply
Re: [RedRum] Rewrite In reply to
Then I can't help you, sorry. I've never used this module (although I should for a number of my sites!).

Does your access_log show host names or IP addresses? There could be a problem with your system converting ip to hostnames?

- wil
Quote Reply
Re: [Wil] Rewrite In reply to
There's no problem with the system.

FTP logs are logging host names correctly and also the following in access.conf works fine:

<Location />
Order Deny,Allow
Deny From ntli.net
</Location>
Quote Reply
Re: [Wil] Rewrite In reply to
Ah I seem to be getting somewhere.

There is something weird going on with my remote host.

Using ntli.net (which is what shows in the logs) doesn't work but using ntl.com in access.conf does.

Also using this in the .htaccess file works too:

RewriteCond %{REMOTE_HOST} ^.*ntli\.net$ [OR]
RewriteCond %{REMOTE_HOST} ^.*ntl\.com$ [OR]
RewriteCond %{REMOTE_HOST} ^.*ntl.*$

Not sure why but maybe my ISP is using an alias or something for my remote host?

Last edited by:

RedRum: Nov 1, 2001, 5:51 AM
Quote Reply
Re: [RedRum] Rewrite In reply to
Well I'm 100% sure I tried this last night but it is working today:

RewriteEngine On
RewriteCond %{REMOTE_HOST} ^.*ntl\.com$
RewriteRule ^(.+) http://www.wiredon.net/img/ [R,L]

Quote Reply
Re: [RedRum] Rewrite In reply to
They could well be using a proxy server, some ip rewriting, or something similar.

- wil
Quote Reply
Re: [Wil] Rewrite In reply to
Turns out my remote host changed from ntli.net to ntl.com overnight :)

It wasn't working with ntli.net last night though so maybe I was trying after it had already changed to ntl.com - who knows - either way it works now!

Last edited by:

RedRum: Nov 1, 2001, 7:25 AM
Quote Reply
Re: [RedRum] Rewrite In reply to
You may want to look at the RewriteLog and RewriteLogLevel commands. Makes debugging rewrite rules much easier. =) Just remember to turn them off once your done.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Rewrite In reply to
Yes I did try those but I get an internal server error when I add them to the .htaccess file so I removed them.

Last edited by:

RedRum: Nov 1, 2001, 8:46 AM
Quote Reply
Re: [RedRum] Rewrite In reply to
I think they must go in the httpd.conf file.. can't be used in .htaccess.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Rewrite In reply to
Angelic....thanks