Rewrite a URL that's already been redirected?

Posted by Jack on Stack Overflow See other posts from Stack Overflow or by Jack
Published on 2010-03-12T00:54:08Z Indexed on 2010/03/12 0:57 UTC
Read the original article Hit count: 278

Filed under:
|
|
|

Hi guys,

I'm running an Apache2 web server with a dynamic IP address. I bought exampledomain.net, and I use no-ip.com's domain-update service to redirect any visitors to my current ip address (endnote #1). For example, someone visits exampledomain.net and they get redirected to 73.181.57.34. It works like a charm. However, it isn't all that user-friendly. Can I rewrite the redirected, ip-address URL?

I tried these rewrite rules in the root folder's .htaccess...

RewriteEngine On
RewriteCond %{HTTP_HOST} ^73\.181\.57\.34:88
RewriteRule ^(.*)$ http://www.exampledomain.net/$1 [L,NC]
# I simplified the RewriteCond. I would use regex in a real situation.

Of course, this creates an infinite loop. The user visits www.exampledomain.net. They're redirected to 73.181.57.34:88 by no-ip. Apache redirects them to www.exampledomain.net which redirects them back to 73.181.57.34:88... so on and so forth.

I'm a noob when it comes to rewriting, but is there a way to rewrite a URL without redirecting?

I tried these rewrite rules too (a shot in the dark)...

RewriteEngine On
RewriteCond %{HTTP_HOST} ^73\.181\.57\.34:88
RewriteRule ^(.*)$ my.exampledomain.net/$1 [L,NC]
# I'd read that Apache replied with a redirect header when you include http

Thanks!


(1) No-IP works like this: You download and install their dynamic update client on your server. Every couple of minutes it polls your server for its current external ip address. If it's changed, it updates your server's ip address in no-ip's records.

© Stack Overflow or respective owner

Related posts about url

Related posts about url-rewriting