Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pretty URL on Virtual Sub Domain

0 views
Skip to first unread message

Acrobatic

unread,
Oct 30, 2009, 11:38:42 PM10/30/09
to
Hello

I'm able to use virtual subdomains with my hosting company, so what
I'd like to do is have addresses like:

apple.mysite.com
banana.mysite.com

go to

http://www.mysite.com/fruit.html?fruit=apple
http://www.mysite.com/fruit.html?fruit=banana

I've setup my .htaccess to allow this, so when I visit
apple.mysite.com it does redirect me to http://www.mysite.com/fruit.php?fruit=apple,
but I want the browser address bar to stay at http://apple.mysite.com
while serving the data from the "fruit.html" file, in this example.

What am I missing?

My .htaccess is

Options +FollowSymLinks
RewriteEngine on

# Extract the subdomain part of domain.com
RewriteCond %{HTTP_HOST} ^([^\.]+)\.mysite\.com$ [NC]

# Check that the subdomain part is not www and ftp and mail
RewriteCond %1 !^(www|ftp|mail)$ [NC]

# Redirect all requests to a php script passing as argument the
subdomain
RewriteRule ^.*$ http://www.mysite.com/fruit.php?fruit=%1 [QSA,L]

TIA
Jeff

HansH

unread,
Oct 31, 2009, 8:44:40 AM10/31/09
to
"Acrobatic" <jbn...@gmail.com> schreef in bericht
news:3698553e-e65e-4adc...@k4g2000yqb.googlegroups.com...

> but I want the browser address bar to stay at http://apple.mysite.com
> while serving the data from the "fruit.html" file, in this example.
>
> What am I missing?
>
> My .htaccess is
>
> Options +FollowSymLinks
> RewriteEngine on
>
> # Extract the subdomain part of domain.com
> RewriteCond %{HTTP_HOST} ^([^\.]+)\.mysite\.com$ [NC]
>
> # Check that the subdomain part is not www and ftp and mail
> RewriteCond %1 !^(www|ftp|mail)$ [NC]
>
> # Redirect all requests to a php script passing as argument the
> subdomain
> RewriteRule ^.*$ http://www.mysite.com/fruit.php?fruit=%1 [QSA,L]

Rewrites manipulate the mapping of URLs to files, unless destination is NOT
a file or folder.
While at it:
- assuming www is the most commonly used prefix, test it first
-and save some time not spent on the other condition-
- assuming 'domain.com' is a constant and the only domain served, don't
test it
- why testing the discarded URL for perhaps having characters between
_start_ and_ end_?
checking for a single character should [in theory] stop right after the
first one

Try these untested lines:
RewriteCond %{HTTP_HOST} !^(www|ftp|mail)\. [NC]


RewriteCond %{HTTP_HOST} ^([^\.]+)\.

RewriteRule .? fruit.php?fruit=%1 [QSA,L]


HansH


Acrobatic

unread,
Oct 31, 2009, 2:35:58 PM10/31/09
to
On Oct 31, 7:44 am, "HansH" <ha...@invalid.invalid> wrote:
> "Acrobatic" <jbn...@gmail.com> schreef in berichtnews:3698553e-e65e-4adc...@k4g2000yqb.googlegroups.com...
>
>
>
> > but I want the browser address bar to stay athttp://apple.mysite.com

> > while serving the data from the "fruit.html" file, in this example.
>
> > What am I missing?
>
> > My .htaccess is
>
> > Options +FollowSymLinks
> > RewriteEngine on
>
> > # Extract the subdomain part of domain.com
> > RewriteCond %{HTTP_HOST} ^([^\.]+)\.mysite\.com$ [NC]
>
> > # Check that the subdomain part is not www and ftp and mail
> > RewriteCond %1 !^(www|ftp|mail)$ [NC]
>
> > # Redirect all requests to a php script passing as argument the
> > subdomain
> > RewriteRule ^.*$http://www.mysite.com/fruit.php?fruit=%1[QSA,L]

>
> Rewrites manipulate the mapping of URLs to files, unless destination is NOT
> a file or folder.
> While at it:
> - assuming www is the most commonly used prefix, test it first
>   -and save some time not spent on the other condition-
> - assuming 'domain.com'  is a constant and the only domain served, don't
> test it
> - why testing the discarded URL for perhaps having characters between
> _start_ and_ end_?
>   checking for a single character should [in theory] stop right after the
> first one
>
> Try these untested lines:
>   RewriteCond %{HTTP_HOST} !^(www|ftp|mail)\. [NC]
>   RewriteCond %{HTTP_HOST} ^([^\.]+)\.
>   RewriteRule .? fruit.php?fruit=%1 [QSA,L]
>
> HansH

Hans, excellent! That worked. Thank you for your help

Jeff

0 new messages