Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 21st July 2006, 15:47
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,036
Thanks: 268
Thanked 152 Times in 132 Posts
Default need some help with a .htaccess rewrite rule..

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..
Reply With Quote
Sponsored Links
  #2  
Old 21st July 2006, 16:51
TheRudy TheRudy is offline
Senior Member
 
Join Date: Dec 2005
Posts: 216
Thanks: 1
Thanked 7 Times in 5 Posts
Default

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.
Reply With Quote
  #3  
Old 21st July 2006, 19:12
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,036
Thanks: 268
Thanked 152 Times in 132 Posts
Default

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!

Last edited by edge; 21st July 2006 at 19:15.
Reply With Quote
  #4  
Old 21st July 2006, 19:34
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,036
Thanks: 268
Thanked 152 Times in 132 Posts
Default

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]
Reply With Quote
  #5  
Old 22nd July 2006, 11:17
TheRudy TheRudy is offline
Senior Member
 
Join Date: Dec 2005
Posts: 216
Thanks: 1
Thanked 7 Times in 5 Posts
Default

R = redirection aka from typed URL to the one you provide in the rule.. You wanted it to stay subdomain, no?
Reply With Quote
  #6  
Old 22nd July 2006, 11:48
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,036
Thanks: 268
Thanked 152 Times in 132 Posts
Default

Quote:
Originally Posted by TheRudy
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]
Reply With Quote
  #7  
Old 22nd July 2006, 16:25
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,744 Times in 2,577 Posts
Default

Quote:
Originally Posted by edge
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).
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #8  
Old 22nd July 2006, 16:54
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,036
Thanks: 268
Thanked 152 Times in 132 Posts
 
Default

Got it!

Code:
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
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ISPConfig, Drupal, and .htaccess jon335 General 23 16th November 2008 13:22
gallerie and rewrite fpl Installation/Configuration 20 14th February 2007 15:21
wordpress MU and ISPconfig .htaccess isues palkat General 4 18th October 2006 11:57
.htaccess never executed galmiche Server Operation 2 4th June 2006 21:44
Drupal and Apache Rewrite Rules andre Server Operation 10 4th May 2006 21:04


All times are GMT +2. The time now is 20:57.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.