View Full Version : need some help with a .htaccess rewrite rule..
edge
21st July 2006, 16:47
I'm trying to do the following with a .htaccess rule (apache2), but till now with no luck.
test-a.website.com should show website.com/test-a/index.html
test-b.website.com should show website.com/test-b/index.html
I would also (if possible) to still show "test-a.website.com" as URL, and not redirect it to "website.com/test-a/inde.html" (same thing for test-b.website.com)
I guess it's done with a rewrite rule.. but how?
Thanks for any info..
TheRudy
21st July 2006, 17:51
Don't think you can do that since by default you don't have wildcard set for subdomains i think.. Try by inserting that code to vhosts.conf file. There it should work since ISPConfig does it the same way if you create a co-domain.
edge
21st July 2006, 20:12
Thanks for the input TheRudy.
I was using the Vhosts_ispconfig.conf to do this, but I was kind of hoping that this could be done with a .htaccess file!
edge
21st July 2006, 20:34
This "kind of" does the job exept that it's showing the new URL!
ReWriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} test-a.website.com$ [NC]
RewriteRule ^(.*)$ http://website.com/test-a/index.html [R]
RewriteCond %{HTTP_HOST} test-b.website.com$ [NC]
RewriteRule ^(.*)$ http://website.com/test-b/index.html [R]
TheRudy
22nd July 2006, 12:17
R = redirection aka from typed URL to the one you provide in the rule.. You wanted it to stay subdomain, no? :)
edge
22nd July 2006, 12:48
R = redirection aka from typed URL to the one you provide in the rule.. You wanted it to stay subdomain, no? :)
Oops... yes.. I wanted to stay in the subdomain.. Lets try without the [R] :)
falko
22nd July 2006, 17:25
Thanks for the input TheRudy.
I was using the Vhosts_ispconfig.conf to do this, but I was kind of hoping that this could be done with a .htaccess file!
You can put the code into the Apache Directives box of the web site in ISPConfig, or you use an .htaccess file (but then you might have to change the AllowOverride line in your main Apache configuration for the /var/www/*/web directory near the end).
edge
22nd July 2006, 17:54
Got it!
RewriteEngine On
RewriteCond %{REQUEST_URI} !^//(.*)?$
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.website\.com$ [NC]
RewriteRule ^(.*)$ //%2/$1 [QSA,L]
url: "test-a.website.com" will now load the stuff that is in "website.com/test-a/" and still show "test-a.website.com" as url
url: "test-b.website.com" will now load the stuff that is in "website.com/test-b/" and still show "test-b.website.com" as url
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.