开发者

subdomains pointing subfolders with mod rewrite

Hi I'm quite new to PHP... And need something to do as fast as I can..

I have some clients within the "clients" directory like here... "http://domain.com/clients/client0001/fluids/..."

I want this URL to be shown in the address bar like this.

"http://client0001.domain.com/fluids/..."

with the help of .htaccess. Any help will be appr开发者_开发知识库eciated ...

Thanks


You can use mod_rewrite to rewrite such URLs:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^./]+)\.example\.com$
RewriteRule !^clients/ clients/%1%{REQUEST_URI} [L]

But your webserver needs to be configured so that it accepts such host names and sends the requests to the proper virtual host.


I've used this before as posted by Gumbo.

Only issue I've had with it is that you can't then use further rewrite rules - so if the site you are serving on the subdomain uses url rewriting, you have to make it its own virtual host.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜