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.
精彩评论