Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
redirect to an external url using .htaccess
Hi all!
I have been trying to make a simple redirection from http://www.mydomain.com.ar/mail/ to http://mail.google.com/hosted/mydomain.com.ar but for some reason I can’t get it to work: it shows the 404 page that is managed by TxP.
I have tried the following
<code>RewriteCond %{HTTP_HOST} ^mydomain\.com\.ar/mail$ [NC]
RewriteRule ^(.*)$ http://mail.google.com/hosted/mydomain.com.ar [R=301,L]</code>
and also
<code>RewriteRule ^http://www\.mydomain\.com\.ar/mail$ http://mail.google.com/a/mydomain.com.ar/ [L]</code>
But I couldn’t make it work. I always get the 404 page.
What am I doing wrong?
Many thanks in advance!
Offline
Re: redirect to an external url using .htaccess
How about:
RedirectMatch permanent ^/mail$ http://mail.google.com/hosted/mydomain.com.ar
?
~Nick
Last edited by NickML (2006-08-30 07:04:29)
Offline
Re: redirect to an external url using .htaccess
Try
redirect permanent /mail http://mail.google.com/hosted/mydomain.com.ar
I don’t think that any pattern matching is neccessary.
Offline
Re: redirect to an external url using .htaccess
hi!
first, thanks to both NickML and wet for your suggestions.
I have tried both, but only the one by wet worked for me like a charm!
many thanks!
Offline
Re: redirect to an external url using .htaccess
Hi!
here again with a new question related to this!
I would like to redirect an old site (old URL) to a new one (new URL).
Right now, I’m using:
<code>
RewriteCond %{HTTP_HOST} ^oldsite\.com.ar$ [NC]
ewriteRule ^(.*)$ http://www.newsite.com.ar/ [R=301,L]
RewriteCond %{HTTP_HOST} ^www.oldsite\.com.ar$ [NC]
RewriteRule ^(.*)$ http://www.newsite.com.ar/ [R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite\.com.ar$ [NC]
RewriteRule ^(.*)$ http://www.newsite.com.ar/ [R=301,L]
RewriteCond %{HTTP_HOST} ^www.oldsite\.com.ar$ [NC]
RewriteRule ^(.*)$ http://www.newsite.com.ar/ [R=301,L]
</code>
I would bet there is a cleaner way…
The one above has a “problem” when an old URL (in a search engine result page) is like this:
www.oldsite.com.ar/catalog/index.php?cPath=28_31
and it is redirected to
www.newsite.com.ar/<b>?cPath=28_31</b>
So, what I want is to redirect any old url (root, folders, subfolders) always to the root of the new site (newsite.com.ar), of course.
Then, if a visitor clicks on an old URL in search engine results page
www.oldsite.com.ar/catalog/index.php?cPath=28_31
he/she will go always to:
www.newsite.com.ar
I have tried:
<code>Redirect permanent / http://www.newsite.com.ar/</code>
But it didnt work as expected.
Thanks in advance.
Last edited by maniqui (2006-09-02 23:34:53)
Offline
Re: redirect to an external url using .htaccess
bump! thanks.
Offline
Re: redirect to an external url using .htaccess
Another bump!
I promise this is the last one. If I don’t get any answer, I will RTFM! :P
Thanks and sorry.
Offline
#8 2006-09-12 18:22:14
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: redirect to an external url using .htaccess
Your first two are identical to the second two, not sure why you did that. And yes, they can be made into one:
RewriteCond %{HTTP_HOST} ^(www\.)?oldsite\.com.ar$ [NC]
RewriteRule .* http://www.newsite.com.ar/ [R=301,L]
Last edited by Mary (2006-09-13 14:31:47)
Offline
Re: redirect to an external url using .htaccess
Thanks for the quick reply and for your suggestion, Mary.
Your suggestiond worked very well, but still, any old url that looks like /catalog/index.php?cPath=28_31 is being rewrited as newsite.com.ar/<strong>?cPath=28_31</strong>.
I would like that all urls will be forced to be rewrotten/redirected just as www.newsite.com.ar/.
Offline
#10 2006-09-13 14:32:21
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: redirect to an external url using .htaccess
I adjusted it. Try again?
Offline
Re: redirect to an external url using .htaccess
Thanks again, Mary.
The adjustment didnt make any noticeable difference. If there is a something like /index.php?cpath=28, all the characters after the ? (including the ?) are being kept after the URL is rewritten.
Perhaps, is there any solution similar to the one suggested by wet but for redirecting everything in the domain? (not just a subdirectory, but all)
Offline
#12 2006-09-14 12:21:06
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: redirect to an external url using .htaccess
You’re not adding the QSA flag anywhere, are you?
Offline