You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Chase <xa...@juun.com> on 2005/07/28 08:19:47 UTC
Re: [users@httpd] [RESOLVED] Regular Expression Question
got it working.
here's what i did:
in /.htaccess, i've got:
RewriteEngine on
RewriteRule ^(.*)$ http://www.foo.com/$1 [R=301,L]
and in /cgi-bin/.htaccess, i've got:
RewriteEngine off
it's not perfect. for instance, if someone requests http://
www.foo.net/cgi-bin/something_else, it won't get redirected to
foo.com, it'll just return a 404 (from foo.net) when it doesn't find
the file on foo.net.
but for all other file requests, it'll work perfectly.
cheers.
- chase
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] [RESOLVED] Regular Expression Question
Posted by Chase <xa...@juun.com>.
> i mean, looking at the script, which i yanked from an online
> tutorial, it's obvious where the problem is:
>
> <?
> Header( "HTTP/1.1 301 Moved Permanently" );
> Header( "Location: http://www.foo.com" );
> ?>
>
> i just need to figure out how in php to get it to respect the
> entire original file path.
>
> it probably won't be too hard. if i get stuck, i'll post on a php
> list.
okay, got it. i hate leaving threads unfinished, because it's
annoying to follow a thread in an archive and hit an unresolved dead
end, so for the sake of those reading this years from now, it's:
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.foo.com" . $_SERVER["REQUEST_URI"] );
?>
... or at least that seems to be working nicely thus far.
the end.
- chase
ps: thanks to dan for getting me back on track with this more
elegant (IMO) solution.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Regular Expression Question
Posted by Chase <xa...@juun.com>.
On Jul 28, 2005, at 1:43 AM, Chase wrote:
>> You could always create an errordocument CGI that returns a
>> LOCATION header that sends them to foo.net :)
>>
>
>
> actually, that was one of the first things i tried, but i couldn't
> get it working.
>
> let me make sure that i understand you:
>
> do you mean to create a 404 page that does the redirection?
>
> if so, what is a straight html example of such a page?
>
> my web host will only allow plain html error pages, so i can't use
> php or whatever. it'll have to be plain, vanilla html.
correction: i was mistaken about not being able to use php for
404s. i can easily override this setting in .htaccess, which i just
tried and it works, but the redirect is just shooting me to the root
of foo.com instead of to the corresponding path.
in other words, if i try:
http://www.foo.net/filename.htm
... instead of going to:
http://www.foo.com/filename.htm
... it goes to:
http://www.foo.net/
i mean, looking at the script, which i yanked from an online
tutorial, it's obvious where the problem is:
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.foo.com" );
?>
i just need to figure out how in php to get it to respect the entire
original file path.
it probably won't be too hard. if i get stuck, i'll post on a php list.
- chase
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Regular Expression Question
Posted by Chase <xa...@juun.com>.
> You could always create an errordocument CGI that returns a
> LOCATION header that sends them to foo.net :)
actually, that was one of the first things i tried, but i couldn't
get it working.
let me make sure that i understand you:
do you mean to create a 404 page that does the redirection?
if so, what is a straight html example of such a page?
my web host will only allow plain html error pages, so i can't use
php or whatever. it'll have to be plain, vanilla html.
- chase
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] [RESOLVED] Regular Expression Question
Posted by "Dan Mahoney, System Admin" <da...@prime.gushi.org>.
On Thu, 28 Jul 2005, Chase wrote:
You could always create an errordocument CGI that returns a LOCATION
header that sends them to foo.net :)
-Dan
> got it working.
>
> here's what i did:
>
> in /.htaccess, i've got:
>
> RewriteEngine on
> RewriteRule ^(.*)$ http://www.foo.com/$1 [R=301,L]
>
>
> and in /cgi-bin/.htaccess, i've got:
>
> RewriteEngine off
>
>
>
> it's not perfect. for instance, if someone requests http://
> www.foo.net/cgi-bin/something_else, it won't get redirected to foo.com, it'll
> just return a 404 (from foo.net) when it doesn't find the file on foo.net.
>
> but for all other file requests, it'll work perfectly.
>
> cheers.
>
> - chase
>
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
--
"I'm sorry, that is bull$@%^, but they did not say 'Exsqueeze Me' A Long Time Ago in a Galaxy Far Far Away."
-Richard Bozzello, on Jar Jar Binks
--------Dan Mahoney--------
Techie, Sysadmin, WebGeek
Gushi on efnet/undernet IRC
ICQ: 13735144 AIM: LarpGM
Site: http://www.gushi.org
---------------------------
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org