Please help in htaccess!

Hello ,

I have programmed an small script for my members

script job is

1- They can create them folder on my site
2- They can create unlimted html pages in them folder on my site !

i have configured wildcard on server and it’s ok

every thing is okay

i need only htaccess file

i want htaccess do that

1 - rewrite [VALUE1].mysite.com ----- mysite.com/folder.php?foldername=[VALUE1]
2 - rewrite [VALUE1].mysite.com/[VALUE2] ---- mysite.com/folder.php?foldername=[VALUE1]&[VALUE2]

above the [VALUE2] is the query for every folder
EXAMPLE

mysite.com/folder.php?foldername=test1&page=about_me&paged=2

Here [VALUE1] is [test1]
[VALUE2] is [page=about_me&paged=2]

Please Help

i finnaly finished my script after 4 months work !

and really need your help !


some one asked this question before
here the post

and they answered him right

but he required only one value [ profile.php?username=[NAME]
i required two values [folder.php?foldername=[VALUE 1]&[VALUE 2]

Regards

Alla,

You are trying to capture the username from the subdomain and a filename, too. No problem.

IMHO, you should NOT attempt to redirect to the main domain but the subdomain should be pointed at the main domain (SHARED DocumentRoot) and allow mod_rewrite to fetch the subdomain’s folder (because it makes your redirections easier when the URL does not change).

1 - rewrite [VALUE1].mysite.com ----- mysite.com/folder.php?foldername=[VALUE1]

mod_rewrite:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\\.mysite\\.com$
RewriteCond %{HTTP_HOST} ^([a-z]+)\\.mysite\\.com [NC]
# NOTA BENE: The subdomain and folder must be lowercase!
RewriteRule ^$ folder.php?foldername=%1 [L]
2 - rewrite [VALUE1].mysite.com/[VALUE2] ---- mysite.com/folder.php?foldername=[VALUE1]&[VALUE2]

continuing the above code:

RewriteCond %{HTTP_HOST} !^www\\.mysite\\.com$
RewriteCond %{HTTP_HOST} ^([a-z]+)\\.mysite\\.com [NC]
# again, the subdomain and folder must be lowercase!
RewriteRule ^([a-z./]+)$ folder.php?foldername=%2&link=$1 [L]
# I added a key name of "link" for $1 to enable it to be accessed properly
# the path/filename must be lowercase letters only (with / and . as appropriate)

It’s NOT rocket science but a simple subset of regular expressions applied to simple Apache variables. Have a look at the tutorial linked in my signature for more information.

Regards,

DK