简体   繁体   中英

subdomain like setup using htaccess

I need a help regarding htaccess. I need a subdomain like setup using htaccess. It should redirect or show the contents from one of my controllers.

For eg:

I have a controller say "view" and method called "site". i would pass some parameters

Current url will be: www.mydomain.com/view/site/name

Now what i need is i should have a setup like following

name.mydomain.com = www.mydomain.com/view/site/name

my current htaccess looks like this

allow from all

Options -Multiviews

RewriteEngine On

Options -Multiviews

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %(REQUEST_FILENAME) !-l

RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA] 

what should i add to it? Please let me know

Thanks in advance

First off - You do not need to repeat Options -Multiviews

And as for the rule

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com
RewriteRule ^(.*)$ http://mydomain.com/view/site/%1/$1 [L,NC,QSA]

the % says: take first parameter from the RewriteCond as it starts with %{HTTP_HOST}

the $ says: take first parameter from the RewriteRule

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM