What I'm trying to do is this:
sub.domain.com
to
domain.com/index.php?q=sub
and
sub.domain.com/somefile.php
to
domain.com/sub/index.php?q=sub&file=somefile.php
and
sub.domain.com/somefile.php?m=12&r=12
to
domain.com/sub/index.php?q=sub&file=somefile&m=12&r=12
and keep the address bar with the subdomain.
I got some code but it's not remotely doing what I need, so any help would be really appreciated.
Thanks!
RewriteEngine On
#Rewrite foo.domain.com/foo/bar to /index.php?q=foo&page=foobar
#in the condition pattern bellow, we match against any http_host string that doesnt start with www
RewriteCond %{HTTP_HOST} ^((?!www).+)\.domain\.com$ [NC]
#if the above condition is met, the rewrite the request
RewriteRule ^(.*)$ /index.php?q=%1&file=$1 [QSA,NC,L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.