How to rewrite ip address to domain.

This is a discussion on How to rewrite ip address to domain. within the Apache Web Server forums, part of the Web Server and Related Forums category; If someone comes into my web page via ip directly, I want to show browser's URL address to domain. ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-24-2008
crazytazo
 
Posts: n/a
Default How to rewrite ip address to domain.


If someone comes into my web page via ip directly,
I want to show browser's URL address to domain.

My server is
Apache 2.2 and Loaded mod_rewrite.

please help me.
  #2 (permalink)  
Old 05-24-2008
phantom
 
Posts: n/a
Default Re: How to rewrite ip address to domain.

"crazytazo" <crazytazo@gmail.com> wrote in message
news:bb2eabf8-b3c8-4cb0-917d-09ec494e131b@u6g2000prc.googlegroups.com...
>
> If someone comes into my web page via ip directly,
> I want to show browser's URL address to domain.
>
> My server is
> Apache 2.2 and Loaded mod_rewrite.
>


try this (replace www.my-domain.com with your domain):
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.my-domain\.com$
RewriteRule ^(.*)$ http://www.my-domain.com$1 [R=301,L]


  #3 (permalink)  
Old 05-26-2008
crazytazo
 
Posts: n/a
Default Re: How to rewrite ip address to domain.

On May 24, 6:13*pm, "phantom" <nob...@blueyonder.invalid> wrote:
> "crazytazo" <crazyt...@gmail.com> wrote in message
>
> news:bb2eabf8-b3c8-4cb0-917d-09ec494e131b@u6g2000prc.googlegroups.com...
>
>
>
> > If someone comes into my web page via ip directly,
> > I want to show browser's URL address to domain.

>
> > My server is
> > Apache 2.2 and Loaded mod_rewrite.

>
> try this (replacewww.my-domain.comwith your domain):
> RewriteEngine on
> RewriteCond %{HTTP_HOST} !^www\.my-domain\.com$
> RewriteRule ^(.*)$http://www.my-domain.com$1[R=301,L]


thanks phantom
that's what i want.
it works well.
thank you again.
  #4 (permalink)  
Old 05-29-2008
BeterHans PAN
 
Posts: n/a
Default Re: How to rewrite ip address to domain.

I wanna know too :)

  #5 (permalink)  
Old 05-29-2008
BeterHans PAN
 
Posts: n/a
Default Re: How to rewrite ip address to domain.

Hello now i find it



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



Try it !
it will rewrite any IP or domain to www.example.com

it works for me




  #6 (permalink)  
Old 05-30-2008
D. Stussy
 
Posts: n/a
Default Re: How to rewrite ip address to domain.

"BeterHans PAN" <beterhans@vnet.citiz.net> wrote in message
news:g1m9k6$jrh$1@news.cn99.com...
> Hello now i find it
>
> RewriteEngine On
> RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
> RewriteRule ^(.*) http://www.example.com/$1 [QSA,L,R]
>
> Try it !
> it will rewrite any IP or domain to www.example.com
>
> it works for me


Putting the "QSA" flag - won't that DOUBLE the query string?

(From http://httpd.apache.org/docs/2.2/mod...l#rewriterule:
Modifying the Query String
By default, the query string is passed through unchanged. You can, however,
create URLs in the substitution string containing a query string part.
Simply use a question mark inside the substitution string to indicate that
the following text should be re-injected into the query string. When you
want to erase an existing query string, end the substitution string with
just a question mark. To combine new and old query strings, use the [QSA]
flag.)

i.e. it gets appended to itself.




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:20 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0