YA htaccess Q
February 28, 2006 2:10 PM
Another redirect question.
My wife has just shifted her weblog from a folder on my server to another server. I want anyone who links to:
http://mysite.com/wife/path/to/file/file.html
to be automatically redirected to:
http://wifesite.com/path/to/file/file.html
Note there are several different paths to files - and this structure will remain identical (for now) on the new server.
I've looked at the other Mod_rewrite and htaccess tagged posts here, and they seem promising, but I can't get them to work. This is likely because I am an idiot, I know, but please be charitable!
My wife has just shifted her weblog from a folder on my server to another server. I want anyone who links to:
http://mysite.com/wife/path/to/file/file.html
to be automatically redirected to:
http://wifesite.com/path/to/file/file.html
Note there are several different paths to files - and this structure will remain identical (for now) on the new server.
I've looked at the other Mod_rewrite and htaccess tagged posts here, and they seem promising, but I can't get them to work. This is likely because I am an idiot, I know, but please be charitable!
Hmm. That php command is all on one line in my file. Sorry about that.
posted by frykitty at 2:49 PM on February 28, 2006
posted by frykitty at 2:49 PM on February 28, 2006
how about a meta refresh tag? maybe even put a note saying "you will be redirected in 3 seconds, please update your bookmarks" as is pretty standard.
link to example.
posted by freudianslipper at 3:35 PM on February 28, 2006
link to example.
posted by freudianslipper at 3:35 PM on February 28, 2006
If you have access to httpd.conf:
RedirectMatch permanent ^/wife(.+)$ http://www.wifesite.com$1
posted by cillit bang at 3:45 PM on February 28, 2006
RedirectMatch permanent ^/wife(.+)$ http://www.wifesite.com$1
posted by cillit bang at 3:45 PM on February 28, 2006
Meta and PHP won't catch all pages on the site (unless you're willing to change all of the pages to have metatags or use this php).
.htaccess is the best way.
(Well php could work if you use htaccess to rewrite all /wife traffic to a PHP page with redirect logic in there, but that sounds like much more work)
posted by holloway at 4:06 PM on February 28, 2006
.htaccess is the best way.
(Well php could work if you use htaccess to rewrite all /wife traffic to a PHP page with redirect logic in there, but that sounds like much more work)
posted by holloway at 4:06 PM on February 28, 2006
oh i see now why a simple meta refresh won't exactly work in your case. well if you didn't get it working perhaps this link would help? link
so I would think if you did something like this all on one line:
Redirect http://mysite.com/wife/path/to/file/ http://wifesite.com/path/to/file/file.html
But I haven't tested it myself.
posted by freudianslipper at 10:42 PM on February 28, 2006
so I would think if you did something like this all on one line:
Redirect http://mysite.com/wife/path/to/file/ http://wifesite.com/path/to/file/file.html
But I haven't tested it myself.
posted by freudianslipper at 10:42 PM on February 28, 2006
You could also use a 404 trick.
Put nothing in the /wife directory but an htaccess file with:
ErrorDocument 404 http://path/to/some/404.cgi
And your 404 CGI munges up the REQUEST_URI environment variable and spits out a Location header.
In Perl, it would look something like:
#!/usr/bin/perl
$foo = $ENV{REQUEST_URI};
$foo =~ s|^/wife||;
print "Location: http://wifesite.com$foo\n\n";
posted by jozxyqk at 3:42 AM on March 1, 2006
Put nothing in the /wife directory but an htaccess file with:
ErrorDocument 404 http://path/to/some/404.cgi
And your 404 CGI munges up the REQUEST_URI environment variable and spits out a Location header.
In Perl, it would look something like:
#!/usr/bin/perl
$foo = $ENV{REQUEST_URI};
$foo =~ s|^/wife||;
print "Location: http://wifesite.com$foo\n\n";
posted by jozxyqk at 3:42 AM on March 1, 2006
Just a followup cause I know people like that...
It turns out there was some issue with the hosting company and htaccess files, that's why it wasn't working in the first place. I resolved that and the standard
I marked that answer best even though that's what I was trying myself in the first place, but thanks everyone for their contributions.
posted by mikel at 10:35 AM on March 7, 2006
It turns out there was some issue with the hosting company and htaccess files, that's why it wasn't working in the first place. I resolved that and the standard
redirect fromhere tohere
syntax is perfect.I marked that answer best even though that's what I was trying myself in the first place, but thanks everyone for their contributions.
posted by mikel at 10:35 AM on March 7, 2006
This thread is closed to new comments.
<?php
header("Location: http://wifesite.com/path/to/file/file.html");
?>
Just make sure .htaccess has the line:
DirectoryIndex index.php
posted by frykitty at 2:48 PM on February 28, 2006