Forum Moderators: phranque

Message Too Old, No Replies

url to subdomian (KEEPING ADDRESS BAR)

General user thinks they are using the http://username.example.com

         

farhad2na2

1:13 pm on Jul 26, 2008 (gmt 0)

10+ Year Member



I would like to poin [username.example.com...] at http://example.com/index.php?username
and would like us to do some url-rewriting such that when a user visits [username.example.com...]
they access the at http://example.com/index.php?username/
but the URLs in the users browsers address bar keeps using the [username.example.com...] sub-domain.
In short - the general user thinks they are using tools on the [username.example.com...]
sub-domain, and know nothing whatsoever about http://example.com/index.php?username.

g1smd

1:53 pm on Jul 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That's a simple rewrite (not a redirect).

The rewrite matches URL requests to internal paths and filenames.

So you'll match the URL http://username.example.com/ to the server path /index.php?username without exposing what that path actually is.

farhad2na2

2:37 pm on Jul 26, 2008 (gmt 0)

10+ Year Member



So what is the correct code? .htaccess code?!
my apache versian is 2.2.8

janharders

3:08 pm on Jul 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain.com$ [NC]
RewriteCond %1 !www [NC]
RewriteRule .* /index.php?username=%1 [L]

should do it (untested).

farhad2na2

3:39 pm on Jul 26, 2008 (gmt 0)

10+ Year Member



OK I found the code, I tested it and it works well.

this is my code:
#http://username.example.com/ to http://example.com/index.php/username
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.example\.com [NC]
RewriteRule (.*) http://example.com/index.php/%1/$1 [P]

Now I want to point [username.example.com...]
to http://example.com/index.php/username/name

would you please help me...

[edited by: jdMorgan at 2:09 pm (utc) on July 27, 2008]
[edit reason] speling [/edit]