Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-08-30 06:21:29

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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!


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#2 2006-08-30 07:04:05

NickML
Member
From: Scotland
Registered: 2006-05-14
Posts: 58
Website

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

#3 2006-08-30 07:11:57

wet
Developer Emeritus
From: Vöcklabruck, Austria
Registered: 2005-06-06
Posts: 3,392
Website GitHub Mastodon

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

#4 2006-08-30 13:58:03

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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!


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#5 2006-08-31 20:36:27

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#6 2006-09-02 23:53:57

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: redirect to an external url using .htaccess

bump! thanks.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#7 2006-09-12 16:31:08

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

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

#9 2006-09-12 20:26:39

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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/.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

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

#11 2006-09-13 16:18:22

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

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

Board footer

Powered by FluxBB