Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-02-03 10:48:31

kees-b
Member
From: middelburg, nl
Registered: 2004-03-03
Posts: 235
Website

Rewrite rule for subdomain.domain.com/anything => domain.com/anything

Hi,

I have a temporary site at subdomain.domain.com and the real site will be on domain.com.
What rewrite rule do I have to use so that /anything on the subdomain points to /anything on the main domain?

So this rule needs to rewrite subdomain.domain.com/anything => domain.com/anything with a 301 permanently moved status code
I found one that rewrites subdomain to domain but that breaks the /anything/ links.

thanks

kees

Offline

#2 2007-02-03 12:50:05

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Rewrite rule for subdomain.domain.com/anything => domain.com/anything

I have used this for a while, that worked for me:

Redirect permanent /subdomain http://subdomain.domain.com

Last edited by els (2007-02-03 12:50:32)

Offline

#3 2007-02-03 14:04:00

kees-b
Member
From: middelburg, nl
Registered: 2004-03-03
Posts: 235
Website

Re: Rewrite rule for subdomain.domain.com/anything => domain.com/anything

Els wrote:

I have used this for a while, that worked for me:
Redirect permanent /subdomain http://subdomain.domain.com

I expected some more regular expressions juggling for the .htaccess file
Did you use this in .htaccess on apache?

-k

Offline

#4 2007-02-03 15:38:58

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Rewrite rule for subdomain.domain.com/anything => domain.com/anything

(EDIT: Deleted my original answer.)

I am now re-reading your post and I think I completely misunderstood :(

I suppose you’ll need to add some special characters at the end of the regular expression, but I’m not very good at those, so I’m sorry, can’t help you there.

Last edited by els (2007-02-03 15:53:30)

Offline

#5 2007-02-03 15:59:36

hcgtv
Plugin Author
From: Miami, Florida
Registered: 2005-11-29
Posts: 2,721
Website

Re: Rewrite rule for subdomain.domain.com/anything => domain.com/anything

You can try this:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain.domain.com [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

Offline

#6 2007-02-03 16:37:25

kees-b
Member
From: middelburg, nl
Registered: 2004-03-03
Posts: 235
Website

Re: Rewrite rule for subdomain.domain.com/anything => domain.com/anything

thanks bert!
that’s the one

-kees

Offline

#7 2007-02-07 11:46:40

kees-b
Member
From: middelburg, nl
Registered: 2004-03-03
Posts: 235
Website

Re: Rewrite rule for subdomain.domain.com/anything => domain.com/anything

Now here’s another related problem that needs rewriting.

How can I rewrite urls that start with (www.)domain.com/Default.lynkx?id= (and some more junk like an id number and more from the old cms) so that they all generate a 404 and don’t interfere with the textpattern article id’s.

kees

Last edited by kees-b (2007-02-07 11:49:08)

Offline

#8 2007-02-08 02:08:25

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Rewrite rule for subdomain.domain.com/anything => domain.com/anything

Offline

#9 2007-02-08 09:07:46

kees-b
Member
From: middelburg, nl
Registered: 2004-03-03
Posts: 235
Website

Re: Rewrite rule for subdomain.domain.com/anything => domain.com/anything

Mary wrote:

http://forum.textpattern.com/viewtopic.php?id=21018
We only need one thread. :)

hi mary,

mmm, my last post here in this thread was only a reference to a completely different question in the other thread. Maybe not so clever to post it this way, and absolutely not meant to crosspost.

Anyway, as you closed the other thread, do you or anyone else have a solution for this new problem I have with outdated url’s that show up after a google search. Google still has indexed pages from the CMS that was used before transfering this site to textpattern. These url’s start with a CMS specific string folowed by ?id= and then an id number and some more text. I explained that with some example links in my other post

What happens: if the ‘old’ id exist in the ‘new’ textpattern site textpattern outputs that new article
If there is a ?id=n string somewhere after the domainname the article with id=n is allways output by textpattern if it exists.

domain.com/sometext?id=nsomemoretext

It is evident that old and new id numbers don’t match so the search result leads to a completely different page. In some time the content will be indexed correctly but the searchbots keep using the old url’s because they coninue working because of the ?id= string.

As I know exactly what string precedes the ?id=n string I am looking for a clever rewrite rule that throws in a 404 if this preceding string is matched.

kees

Last edited by kees-b (2007-02-08 09:11:05)

Offline

#10 2010-01-04 15:46:08

maxvoltar
Member
From: Machelen, Belgium
Registered: 2007-08-16
Posts: 76
Website

Re: Rewrite rule for subdomain.domain.com/anything => domain.com/anything

Hey everyone, I had a kinda similar question, but instead of going from http://subdomain.domain.com to http://domain.com, I need to reroute all articles with an URL like http://domain.com/articles/[string] and http://domain.com/notes/[string] to http://subdomain.domain.com/articles/[string] and http://subdomain.domain.com/notes/[string].

Any ideas?


Textpattern projects: Maxvoltar, Made by Elephant, Twunch

Offline

#11 2010-01-04 16:30:01

graeme
Plugin Author
Registered: 2004-06-21
Posts: 337
Website

Re: Rewrite rule for subdomain.domain.com/anything => domain.com/anything

@maxvoltar – how about this?

RewriteEngine on

RewriteCond %{HTTP_HOST} !^subdomain\.domain\.com [NC]
RewriteCond %{REQUEST_URI} ^/(articles|notes)/ [NC]
RewriteRule (.*) http://subdomain.domain.com/$1 [R=301,L]

Offline

#12 2010-01-04 17:46:41

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Rewrite rule for subdomain.domain.com/anything => domain.com/anything

Can someone please explain to me the difference between Graeme’s rule and this (in .htaccess in the domain root):

Redirect 301 /articles http://subdomain.domain.com/articles
Redirect 301 /notes http://subdomain.domain.com/notes

…and if there is a difference, the pros and cons of both?

Offline

Board footer

Powered by FluxBB