Forum Moderators: phranque
############################
RewriteEngine On
rewritebase /
php_flag register_globals on
Options +FollowSymLinks
Options -Indexes
RewriteCond %{HTTP_HOST} !^www\.my-domain\.info$ [NC]
RewriteCond %{HTTP_HOST} ^([a-z0-9-]+)\.my-domain\.info$ [NC]
RewriteRule ^(.*$) sub/%1/$1 [L]
############################
... sometime works, sometime no :( its true ?
i'd like if some directory (subdomain) isn't create .. so go 404.php .. now this write err500
---
my "dream" are :
automatic create subdomains with create directory
automatic-subdomain.my-domain.info/
=> my-domain.info/sub/automatic-subdomain/index.php
automatic-subdomain.my-domain.info/some
=> my-domain.info/sub/automatic-subdomain/some.php
automatic-subdomain.my-domain.info/some/somethink
=> my-domain.info/sub/automatic-subdomain/some.php?cat=somethink
automatic-subdomain.my-domain.info/some/somethink/somepage
=> my-domain.info/sub/automatic-subdomain/some.php?cat=somethink&page=somepage
many thanks.
Rewrite only if the requested URL resolves to an existing directory and/or file in the /subs/ folder:
RewriteEngine On
RewriteBase /
php_flag register_globals on
Options +FollowSymLinks -Indexes
#
RewriteCond $1 !^sub/
RewriteCond %{HTTP_HOST} !^www\.my-domain\.info [NC]
RewriteCond %{HTTP_HOST} ^([a-z0-9\-]+)\.my-domain\.info
RewriteCond %{DOCUMENT_ROOT}/sub/%1/$1% -f [OR]
RewriteCond %{DOCUMENT_ROOT}/sub/%1/$1% -d
RewriteRule ^(.*)$ sub/%1/$1% [L]
-or-
Allow directory indexes of subdomain folders which do not have any index file:
RewriteEngine On
RewriteBase /
php_flag register_globals on
Options +FollowSymLinks [b]+I[/b]ndexes
#
RewriteCond $1 !^sub
RewriteCond %{HTTP_HOST} !^www\.my-domain\.info [NC]
RewriteCond %{HTTP_HOST} ^([a-z0-9\-]+)\.my-domain\.info
RewriteRule ^(.*)$ sub/%1/$1 [L]
After you get the subdomain->folder rewrite working, then you can modify the code to rewrite to a script like "some.php".
The RewriteCond at the top prevents an 'infinite' rewriting loop.
Note that there are several other changes to patterns, anchoring, and flags. These are intended to avoid problems -- some of which could have been serious.
Jim
###################################
RewriteEngine On
RewriteBase /
php_flag register_globals on
Options +FollowSymLinks +Indexes
RewriteCond $1 !^sub
RewriteCond %{HTTP_HOST} !^www\.my-domain\.info$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([[:alnum:]-]+)\.my-domain\.info$ [NC]
RewriteRule ^(.*$) sub/file.php?sub=%2 [L]
###################################
it makes ..
www.my-domain.info => www.my-domain.info/index.php
(www.)subdomain.my-domain.info => www.my-domain.info/sub/file.php?sub=subdomain
(www.)subdomain.my-domain.info/somethink/else/ => www.my-domain.info/sub/file.php?sub=subdomain
and by php > REQUEST_URI .. i will get "/somethink/else/", where i explode "/" and i get category, page etc. by position in url.
I want to using by 1 file - file.php, where i need know so i have this subdomains, and im in this location.
its possible or somewhere have better idea ?