freelanceprogrammers.org Forum Index » PHP

php and htaccess


View user's profile Post To page top
andufo1982 Posted: Thu Nov 24, 2005 8:24 pm


Joined: 20 Nov 2005

Posts: 5
php and htaccess
Hi...
i know this URL Rewriting Guide stuff isnt PHP per se, but since all
(good) php developers run their apps on Apache Webservers, its worth
asking for:

How can I redirect all incoming traffic from www.server1.com to
www.server2.com with htaccess rewrite`s conditions and rules? the
catch is that it also has to work with urls like
www.server1.com/about_us/ » www.server2.com/about_us/ .....etc

I tried this block of code here (found on
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html), but didnt do
the trick:
RewriteCond %{REMOTE_HOST} !^.+.from-here.com$
RewriteRule ^(/~.+) http://www.to-here.com/$1 [R,L]

Im really desperate to find a solution.

Thanks,
IIG Andres Santos
Móvil » (593) 9 7026627
Reply with quote
Send private message
View user's profile Post To page top
derekscruggs Posted: Thu Nov 24, 2005 10:34 pm


Joined: 05 Apr 2005

Posts: 11
php and htaccess
I`m not an expert on mod_rewrite, but one thing that Jumped out at me is
you`re using {REMOTE_HOST} when I think you should be using {HTTP_HOST}. I
believe {REMOTE_HOST} refers to the host name of the browsing client, not
the server host.

There`s a good cheat sheet at
http://www.ilovejackdaniels.com/cheat-sheets/mod_rewrite-cheat-sheet/ that
includes an example similar to what you`re attempting.

Good luck!

-Derek

> -----Original Message-----
> From: php-objects@yahoogroups.com
> [mailto:php-objects@yahoogroups.com] On Behalf Of Andres Santos
> Sent: Thursday, November 24, 2005 7:24 AM
> To: php-objects@yahoogroups.com
> Subject: [php-objects] php and htaccess
>
>
> Hi...
> i know this URL Rewriting Guide stuff isnt PHP per se, but since all
> (good) php developers run their apps on Apache Webservers, its worth
> asking for:
>
> How can I redirect all incoming traffic from www.server1.com to
> www.server2.com with htaccess rewrite`s conditions and rules? the
> catch is that it also has to work with urls like
> www.server1.com/about_us/ » www.server2.com/about_us/ .....etc
>
> I tried this block of code here (found on
> http://httpd.apache.org/docs/2.0/misc/rewriteguide.html), but didnt do
> the trick:
> RewriteCond %{REMOTE_HOST} !^.+.from-here.com$
> RewriteRule ^(/~.+) http://www.to-here.com/$1 [R,L]
>
> Im really desperate to find a solution.
>
> Thanks,
> IIG Andres Santos
> Móvil » (593) 9 7026627
>
>
> ------------------------ Yahoo! Groups Sponsor
> --------------------~-->
> Get fast access to your favorite Yahoo! Groups. Make Yahoo!
> your home page
> http://us.click.yahoo.com/dpRU5A/wUILAA/yQLSAA/saFolB/TM
> --------------------------------------------------------------
> ------~->
>
> PHP Data object relational mapping generator -
> http://www.meta-language.net/
> Yahoo! Groups Links
>
>
>
>
>
Reply with quote
Send private message
View user's profile Post To page top
andufo1982 Posted: Thu Nov 24, 2005 11:17 pm


Joined: 20 Nov 2005

Posts: 5
php and htaccess
Thanks Derek, I downloaded the sheet. However, i came up with this solution:

<IfModule mod_rewrite.c>

RewriteEngine On
#RewriteBase /

RewriteCond %{HTTP_HOST} !^server1.com$ [NC]
RewriteRule ^(.*)$ http://server2.com/$1 [R=301,L]

</IfModule>



On 11/24/05, Derek Scruggs <derek@...> wrote:
>
> I`m not an expert on mod_rewrite, but one thing that Jumped out at me is
> you`re using {REMOTE_HOST} when I think you should be using {HTTP_HOST}. I
> believe {REMOTE_HOST} refers to the host name of the browsing client, not
> the server host.
>
> There`s a good cheat sheet at
> http://www.ilovejackdaniels.com/cheat-sheets/mod_rewrite-cheat-sheet/ that
> includes an example similar to what you`re attempting.
>
> Good luck!
>
> -Derek
>
> > -----Original Message-----
> > From: php-objects@yahoogroups.com
> > [mailto:php-objects@yahoogroups.com] On Behalf Of Andres Santos
> > Sent: Thursday, November 24, 2005 7:24 AM
> > To: php-objects@yahoogroups.com
> > Subject: [php-objects] php and htaccess
> >
> >
> > Hi...
> > i know this URL Rewriting Guide stuff isnt PHP per se, but since all
> > (good) php developers run their apps on Apache Webservers, its worth
> > asking for:
> >
> > How can I redirect all incoming traffic from www.server1.com to
> > www.server2.com with htaccess rewrite`s conditions and rules? the
> > catch is that it also has to work with urls like
> > www.server1.com/about_us/ » www.server2.com/about_us/ .....etc
> >
> > I tried this block of code here (found on
> >
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html),<http://httpd.apache.or
g/docs/2.0/misc/rewriteguide.html%29,>but didnt do
> > the trick:
> > RewriteCond %{REMOTE_HOST} !^.+.from-here.com$
> > RewriteRule ^(/~.+) http://www.to-here.com/$1 [R,L]
> >
> > Im really desperate to find a solution.
> >
> > Thanks,
> > IIG Andres Santos
> > Móvil » (593) 9 7026627
> >
> >
> > ------------------------ Yahoo! Groups Sponsor
> > --------------------~-->
> > Get fast access to your favorite Yahoo! Groups. Make Yahoo!
> > your home page
> > http://us.click.yahoo.com/dpRU5A/wUILAA/yQLSAA/saFolB/TM
> > --------------------------------------------------------------
> > ------~->
> >
> > PHP Data object relational mapping generator -
> > http://www.meta-language.net/
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
>
>
>
> PHP Data object relational mapping generator -
> http://www.meta-language.net/
>
>
>
> SPONSORED LINKS
> Php
developer<http://groups.yahoo.com/gads?t=ms&k=Php+developer&w1=Php+developer&w2=
Basic+programming+language&w3=Computer+programming+languages&w4=Programming+lang
uages&w5=Object+oriented+programming&w6=Object+oriented+programming+tutorial&c=6
&s=189&.sig=Go57PZfEJUXyhVMKXHevgQ> Basic
> programming
language<http://groups.yahoo.com/gads?t=ms&k=Basic+programming+language&w1=Php+d
eveloper&w2=Basic+programming+language&w3=Computer+programming+languages&w4=Prog
ramming+languages&w5=Object+oriented+programming&w6=Object+oriented+programming+
tutorial&c=6&s=189&.sig=bhALr1AysJyo_QtFkNs-_g> Computer
> programming
languages<http://groups.yahoo.com/gads?t=ms&k=Computer+programming+languages&w1=
Php+developer&w2=Basic+programming+language&w3=Computer+programming+languages&w4
=Programming+languages&w5=Object+oriented+programming&w6=Object+oriented+program
ming+tutorial&c=6&s=189&.sig=crWMbNuTpQo7GcDczXxC7g> Programming
>
languages<http://groups.yahoo.com/gads?t=ms&k=Programming+languages&w1=Php+devel
oper&w2=Basic+programming+language&w3=Computer+programming+languages&w4=Programm
ing+languages&w5=Object+oriented+programming&w6=Object+oriented+programming+tuto
rial&c=6&s=189&.sig=ilvPwIkcb6Rcgq8rB1VUuQ> Object
> oriented
programming<http://groups.yahoo.com/gads?t=ms&k=Object+oriented+programming&w1=P
hp+developer&w2=Basic+programming+language&w3=Computer+programming+languages&w4=
Programming+languages&w5=Object+oriented+programming&w6=Object+oriented+programm
ing+tutorial&c=6&s=189&.sig=X-egmMGYu6ib76_snuXIAQ> Object
> oriented programming
tutorial<http://groups.yahoo.com/gads?t=ms&k=Object+oriented+programming+tutoria
l&w1=Php+developer&w2=Basic+programming+language&w3=Computer+programming+languag
es&w4=Programming+languages&w5=Object+oriented+programming&w6=Object+oriented+pr
ogramming+tutorial&c=6&s=189&.sig=TYAiLWTbKMLDLqFwDSFxFw>
> ------------------------------
> YAHOO! GROUPS LINKS
>
>
> - Visit your group
"php-objects<http://groups.yahoo.com/group/php-objects>"
> on the web.
>
> - To unsubscribe from this group, send an email to:
>
php-objects-unsubscribe@yahoogroups.com<php-objects-unsubscribe@yahoogroups.com?
subject=Unsubscribe>
>
> - Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------
>



--

Slds,
IIG Andres Santos

Móvil » (593) 9 7026627
Weblog » www.andufo.net
Fotolog » fotolog.andufo.net

*****************************
CEO » www.egobits.com
*****************************


[Non-text portions of this message have been removed]
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help