Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 3.0
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: Subdomain to querystring rewrite Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
barisergin
Newbie
Newbie


Joined: 26 September 2003
Location: Turkey
Online Status: Offline
Posts: 31
Posted: 23 July 2010 at 11:49am | IP Logged Quote barisergin

What's the best code to convert:

ru.domain.com

to

domain.com/?lang=ru

But I need it to add this lang=ru to any URL in
subdomain..

That means if:

ru.domain.com/content/23252

then it should be:

domain.com/content.asp?id=23252&lang=ru

Thanks!
Back to Top View barisergin's Profile Search for other posts by barisergin Visit barisergin's Homepage
 
AndrushkaUS
Admin Group
Admin Group


Joined: 13 November 2009
Location: United States
Online Status: Offline
Posts: 3159
Posted: 26 July 2010 at 5:07am | IP Logged Quote AndrushkaUS

Hello,

please try using the following:

Code:
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP:Host} ^ru\.domain\.com$
RewriteRule (.*) http://www.domain.com/$1 [NC,R=301,L]


But I haven't got the idea with
Code:
ru.domain.com/content/23252
then it should be:
domain.com/content.asp?id=23252〈=ru

Does it need to append anything with RU?

The rule itself would be:
Code:
RewriteCond %{HTTP:Host} ^ru\.domain\.com$
RewriteRule ^content/(\d+)$ content.asp?id=$1 [NC,L]


Regards
Andrew

__________________
The will to conquer is the first condition of VICTORY
Back to Top View AndrushkaUS's Profile Search for other posts by AndrushkaUS
 
barisergin
Newbie
Newbie


Joined: 26 September 2003
Location: Turkey
Online Status: Offline
Posts: 31
Posted: 26 July 2010 at 6:41am | IP Logged Quote barisergin

Hi Andrew,

I forgot to add that, I need to add /RU to the
querystring as &lang=subdomain

let's try this one for example:

http://ru.oyunvs.com/kat/name

should be:

http://oyunvs.com/page.aspx?lang=ru&kat=kat&name=name

Is it more clear to show what I need?

Thanks!

Baris
Back to Top View barisergin's Profile Search for other posts by barisergin Visit barisergin's Homepage
 
AndrushkaUS
Admin Group
Admin Group


Joined: 13 November 2009
Location: United States
Online Status: Offline
Posts: 3159
Posted: 26 July 2010 at 8:05am | IP Logged Quote AndrushkaUS

For this case, please, try the following:

Code:
RewriteCond %{HTTP:Host} ^ru\.domain\.com$
RewriteRule ^([^/]+)/([^/]+)$ page.aspx?lang=ru&kat=$1&name=$2 [NC,L]


Regards
Andrew

__________________
The will to conquer is the first condition of VICTORY
Back to Top View AndrushkaUS's Profile Search for other posts by AndrushkaUS
 
barisergin
Newbie
Newbie


Joined: 26 September 2003
Location: Turkey
Online Status: Offline
Posts: 31
Posted: 26 July 2010 at 8:08am | IP Logged Quote barisergin

How about having a dynamic subdomain for all other
languages?
Back to Top View barisergin's Profile Search for other posts by barisergin Visit barisergin's Homepage
 
AndrushkaUS
Admin Group
Admin Group


Joined: 13 November 2009
Location: United States
Online Status: Offline
Posts: 3159
Posted: 26 July 2010 at 8:19am | IP Logged Quote AndrushkaUS

As you wish, master:

Code:
RewriteCond %{HTTP:Host} ^?!(?:www)([^.])+\.domain\.com$
RewriteRule ^([^/]+)/([^/]+)$ page.aspx?lang=%1&kat=$1&name=$2 [NC,L]


Edited by AndrushkaUS - 26 July 2010 at 8:21am


__________________
The will to conquer is the first condition of VICTORY
Back to Top View AndrushkaUS's Profile Search for other posts by AndrushkaUS
 
barisergin
Newbie
Newbie


Joined: 26 September 2003
Location: Turkey
Online Status: Offline
Posts: 31
Posted: 26 July 2010 at 8:20am | IP Logged Quote barisergin

But in this sample, the language is still hardcoded as "ru"
?
Back to Top View barisergin's Profile Search for other posts by barisergin Visit barisergin's Homepage
 
AndrushkaUS
Admin Group
Admin Group


Joined: 13 November 2009
Location: United States
Online Status: Offline
Posts: 3159
Posted: 26 July 2010 at 8:23am | IP Logged Quote AndrushkaUS

I updated, sorry

__________________
The will to conquer is the first condition of VICTORY
Back to Top View AndrushkaUS's Profile Search for other posts by AndrushkaUS
 
barisergin
Newbie
Newbie


Joined: 26 September 2003
Location: Turkey
Online Status: Offline
Posts: 31
Posted: 26 July 2010 at 8:28am | IP Logged Quote barisergin

Thank you very much, I'll try it right now! :)
Back to Top View barisergin's Profile Search for other posts by barisergin Visit barisergin's Homepage
 
barisergin
Newbie
Newbie


Joined: 26 September 2003
Location: Turkey
Online Status: Offline
Posts: 31
Posted: 27 July 2010 at 8:24am | IP Logged Quote barisergin

Hi Andrew,

I couldn't make this code work with this url:

ru.oyunvs.com/action/speedracer

I'm either getting rewrite syntax error, or if I modify
it, I'm getting file not found error on IIS..

Should be hitting:

oyunvs.com/page.aspx?lang=ru&kat=action&slug=speedracer

Am I doing something wrong?
Back to Top View barisergin's Profile Search for other posts by barisergin Visit barisergin's Homepage
 
AndrushkaUS
Admin Group
Admin Group


Joined: 13 November 2009
Location: United States
Online Status: Offline
Posts: 3159
Posted: 28 July 2010 at 3:11am | IP Logged Quote AndrushkaUS

Would you, please, provide the rewrite.log for the testing request?
Logging issues described in FAQ

Regards
Andrew

__________________
The will to conquer is the first condition of VICTORY
Back to Top View AndrushkaUS's Profile Search for other posts by AndrushkaUS
 
barisergin
Newbie
Newbie


Joined: 26 September 2003
Location: Turkey
Online Status: Offline
Posts: 31
Posted: 06 August 2010 at 8:15am | IP Logged Quote barisergin

Hi Andrew,

I managed to solve this problem, this code works well:

RewriteCond %{HTTP:Host}
^(?!www\.)([^.]+)\.wildcardny\.com [NC]
RewriteRule (.*)/(.*)/ /oyn.aspx?lang=%1&cat=$1&slug=$2

But now I have another problem..
Images and CSS are broken.

This is an image, but trying to rewrite it to an aspx
page:

http://us.wildcardny.com/images/logo.gif

Can you help me exclude images and css in the rule I've
provided?
Back to Top View barisergin's Profile Search for other posts by barisergin Visit barisergin's Homepage
 
barisergin
Newbie
Newbie


Joined: 26 September 2003
Location: Turkey
Online Status: Offline
Posts: 31
Posted: 07 August 2010 at 5:46pm | IP Logged Quote barisergin

There is also one more question:

http://de.wildcardny.com

should go to:

/ana.aspx?lang=de

(where "de" is a wildcard)

But this should work with the rules above...

Thanks!

Edited by barisergin - 07 August 2010 at 5:47pm
Back to Top View barisergin's Profile Search for other posts by barisergin Visit barisergin's Homepage
 
barisergin
Newbie
Newbie


Joined: 26 September 2003
Location: Turkey
Online Status: Offline
Posts: 31
Posted: 10 August 2010 at 6:46pm | IP Logged Quote barisergin

a reminder :)
Back to Top View barisergin's Profile Search for other posts by barisergin Visit barisergin's Homepage
 
AndrushkaUS
Admin Group
Admin Group


Joined: 13 November 2009
Location: United States
Online Status: Offline
Posts: 3159
Posted: 11 August 2010 at 4:07am | IP Logged Quote AndrushkaUS

Hello,

sorry, i've been on a vacation.
So, the rules would look like:

Code:
Can you help me exclude images and css in the rule I've provided?

RewriteCond %{HTTP:Host} ^(?!www\.)([^.]+)\.wildcardny\.com [NC]
RewriteCond %{REQUEST_URI} !^.*\.(?:jpg|gif|css)$
RewriteRule ([^/]+)/(.+)$ /oyn.aspx?lang=%1&cat=$1&slug=$2

Code:
There is also one more question:
http://de.wildcardny.com
should go to:
/ana.aspx?lang=de


RewriteCond %{HTTP:Host} ^(?!www\.)([^.]+)\.wildcardny\.com [NC]
RewriteRule ^$ /ana.aspx?lang=%1 [NC,L]

Regards
Andrew

__________________
The will to conquer is the first condition of VICTORY
Back to Top View AndrushkaUS's Profile Search for other posts by AndrushkaUS
 
barisergin
Newbie
Newbie


Joined: 26 September 2003
Location: Turkey
Online Status: Offline
Posts: 31
Posted: 11 August 2010 at 10:19am | IP Logged Quote barisergin

Hi Andrew,

Hope you had a good vacation, and thanks a lot for the
response... It's working just as I planned.

Is there a way to put specific exceptions, and alternate
rules for certain folders?

Like:
de.wildcardny.com/aktion/lander
will go to:
/oyn.aspx?lang=de&kat=aktion&slug=lander

but:
de.wildcardny.com/search/anykeyword
will go to
/search.aspx?lang=de&keyword=anykeyword

is this possible?

(/search/ parameter has some alternatives, like in
German, Russian etc)

Back to Top View barisergin's Profile Search for other posts by barisergin Visit barisergin's Homepage
 
barisergin
Newbie
Newbie


Joined: 26 September 2003
Location: Turkey
Online Status: Offline
Posts: 31
Posted: 11 August 2010 at 5:32pm | IP Logged Quote barisergin

Disregard my last question, I solved it using samples
provided by you earlier, thanks again!

But I have another question...
I have 30k pages indexed in a URL schema that I'm going
to change.

Currently it is:

oyunvs.com/DE/
oyunvs.com/DE/aktion
oyunvs.com/DE/aktion/lander

but it'll be:

de.oyunvs.com
de.oyunvs.com/aktion
de.oyunvs.com/aktion/lander

Is there an easy way to 301 redirect those old links to
the new format so I can still use that Google traffic?
Only major change is, moving language from a folder to a
subdomain..

Back to Top View barisergin's Profile Search for other posts by barisergin Visit barisergin's Homepage
 
AndrushkaUS
Admin Group
Admin Group


Joined: 13 November 2009
Location: United States
Online Status: Offline
Posts: 3159
Posted: 12 August 2010 at 1:36am | IP Logged Quote AndrushkaUS

Seems like this will work:

# 301 redirect to new structure
RewriteCond %{HTTP:HOST} ^oyunvs.com$
RewriteRule ^DE/(.*)$ http://de.oyunvs.com/$1 [NC,R=301,L]

# rewrite back to real paths
RewriteCond %{HTTP:HOST} ^de.oyunvs.com$
RewriteRule ^(.*)$ http://oyunvs.com/DE/$1 [NC,P]

Regards
Andrew


__________________
The will to conquer is the first condition of VICTORY
Back to Top View AndrushkaUS's Profile Search for other posts by AndrushkaUS
 
barisergin
Newbie
Newbie


Joined: 26 September 2003
Location: Turkey
Online Status: Offline
Posts: 31
Posted: 12 August 2010 at 7:26am | IP Logged Quote barisergin

Hi Andrew,

But this rewrite rule will only work with DE..
We have around 10 different language options.
oyunvs.com/DE
oyunvs.com/RU
etc..

Can we put some wildcard in there?
Back to Top View barisergin's Profile Search for other posts by barisergin Visit barisergin's Homepage
 
AndrushkaUS
Admin Group
Admin Group


Joined: 13 November 2009
Location: United States
Online Status: Offline
Posts: 3159
Posted: 12 August 2010 at 7:46am | IP Logged Quote AndrushkaUS

I see,
if they are always 2-digit:

# 301 redirect to new structure
RewriteCond %{HTTP:HOST} ^oyunvs\.com$
RewriteRule ^(..)/(.*)$ http://$1.oyunvs.com/$2 [NC,R=301,L]

# rewrite back to real paths
RewriteCond %{HTTP:HOST} ^(..)\.oyunvs\.com$
RewriteRule ^(.*)$ http://oyunvs.com/%1/$1 [NC,P]

Regards
Andrew

__________________
The will to conquer is the first condition of VICTORY
Back to Top View AndrushkaUS's Profile Search for other posts by AndrushkaUS
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You can vote in polls in this forum