Domain Handling

Using a single web hosting account to host multiple sites

Domain Handling

Postby fukid » Sat Dec 09, 2006 10:34 am

hi,


i want to convert
"XXX.domain.com/" -> www.domain.com/photo.php?usr=XXX

and

"XXX.domain.com/YYY_ZZZ.jpg" -> www.domain.com/showphoto.php?usr=XXX&photoid=YYY^resize=ZZZ


THANKS
fukid
 
Posts: 7
Joined: Sat Dec 02, 2006 7:35 am

Postby richardk » Sat Dec 09, 2006 11:43 am

You need DNS for the sub domains.
the sub domains need to point to your main document root.

Then you can use the following in a .htaccess file in your document root:
Code: Select all
Options +FollowSymLinks

RewriteCond %{HTTP_HOST}     !^www\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com$ [NC]
RewriteRule ^$ /photo.php?usr=%1 [QSA,L]

RewriteCond %{HTTP_HOST}     !^www\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com$ [NC]
RewriteRule ^([^/]+)_([^/]+)\.jpg$ /photo.php?usr=%1&photoid=$1^resize=$2 [QSA,L]


Did you really want ^? Not &?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby fukid » Mon Dec 11, 2006 1:59 am

richardk wrote:Did you really want ^? Not &?



what is the difference between ^? and &?




moreover, how can i convert


domain.com/admin?XXXXXX -> domain.com/abc.php?action=admin&XXXXXX


thank you very much
fukid
 
Posts: 7
Joined: Sat Dec 02, 2006 7:35 am

Postby richardk » Mon Dec 11, 2006 11:57 am

what is the difference between ^? and &?

&s usually separate the GET parameters, eg. /posting.php?mode=reply&t=2514. I just thought you might have mistyped it and that pointing it out would be better than letting you try it and it not working.

domain.com/admin?XXXXXX -> domain.com/abc.php?action=admin&XXXXXX

Code: Select all
RewriteRule ^admin/?$ /abc.php?action=admin [QSA,L]

Or
Code: Select all
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /abc.php?action=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby fukid » Tue Dec 12, 2006 9:56 am

o thanks, but why do we need to add
Code: Select all
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d

?

also, i am try to redirect XXXX.domain.com/123/ to photo.php?bkid=123&usr=XXXX , which XXXX is number or english,
123 is number only,

this is my code
Code: Select all
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/([0-9]+)$ [NC]
RewriteRule ^$ /photo.php?bkid=%2&usr=%1 [QSA,L]


but it seems can't work ~
fukid
 
Posts: 7
Joined: Sat Dec 02, 2006 7:35 am

Postby richardk » Tue Dec 12, 2006 10:52 am

why do we need to add

So it doesn't rewrite abc.php (or any real file/directory) and cause a loop.

Code: Select all
RewriteCond %{HTTP_HOST}     !^www\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com$ [NC]
RewriteRule ^([0-9]+)/?$ /photo.php?bkid=$1&usr=%1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby fukid » Wed Dec 13, 2006 3:20 am

richardk wrote:
why do we need to add

So it doesn't rewrite abc.php (or any real file/directory) and cause a loop.

Code: Select all
RewriteCond %{HTTP_HOST}     !^www\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com$ [NC]
RewriteRule ^([0-9]+)/?$ /photo.php?bkid=$1&usr=%1 [QSA,L]



thanks,richardk i learnt a lots~
fukid
 
Posts: 7
Joined: Sat Dec 02, 2006 7:35 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 101 guests

cron