Forum Moderators: phranque

Message Too Old, No Replies

subdomain mod rewrite

         

cornholio

7:59 pm on Feb 19, 2008 (gmt 0)

10+ Year Member



Hi,

I want to do somethink like this:

when I use this

www.orange.domain.com/contact.html

Should execute this:

www.domain.com/index.php?subdomain=orange&action=contact

I know how to do this:

To co wiem jak zrobiæ to

www.orange.domain.com
www.domain.com/index.php?subdomain=orange

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?(.*).domain.com$
RewriteRule ^([^*]*)$ index.php?subdomain=%2

I've found similar topic hire [webmasterworld.com...] but I can't rework it for my needs

gergoe

7:34 pm on Feb 22, 2008 (gmt 0)

10+ Year Member



What you want to achieve is not clear, but to answer your question (without predicting it's side effects, like broken images), you can do this (in a .htaccess file):

Options +FollowSymLinks 
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?(.*).domain.com$ [NC]
# This rule will match on any url which does not contain a slash
RewriteRule ^([^/]*)$ index.php?subdomain=%2&action=$1 [L]

This will turn www.orange.domain.com/contact.html into index.php?subdomain=orange&action=contact.html, but for example www.orange.domain.com/images/spacer.gif, www.orange.domain.com/contact and www.orange.domain.com/contact/ would be left untouched.