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. ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
"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] |
|
|||
|
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. |
|
|||
|
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 |
|
|||
|
"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. |