Apache URL rewriting cant seem to rewrite to directory

  • aot2002
  • Born
  • Born
  • No Avatar
  • Joined: Oct 09, 2007
  • Posts: 3
  • Status: Offline

Post October 14th, 2007, 2:12 pm

ive got serveral directories and domain names but wanted to have an easy wasy not have to add new virtual hosts when i add domains

so far ive got this
Code: [ Select ]
RewriteEngine On
RewriteRule ^(.*)$ /web/%{HTTP_HOST}$1
  1. RewriteEngine On
  2. RewriteRule ^(.*)$ /web/%{HTTP_HOST}$1


but this will not work because some users use a http://www.mydomain.com and some use mydomain.com
so it will look for

/web/mydomain.com WORKS
/web/www.mydomain.com doesnt exist and i dont want to have to create two directories.

anyone know what i can do?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post October 14th, 2007, 2:12 pm

  • aot2002
  • Born
  • Born
  • No Avatar
  • Joined: Oct 09, 2007
  • Posts: 3
  • Status: Offline

Post October 14th, 2007, 3:51 pm

Code: [ Select ]
RewriteCond %{HTTP_HOST} ^www\.(([a-z0-9_]+\.)?(.*))$ [NC]
RewriteRule .? /web/%1%{REQUEST_URI} [L]

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .? http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  1. RewriteCond %{HTTP_HOST} ^www\.(([a-z0-9_]+\.)?(.*))$ [NC]
  2. RewriteRule .? /web/%1%{REQUEST_URI} [L]
  3. RewriteCond %{HTTP_HOST} !^www\. [NC]
  4. RewriteRule .? http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


did the trick
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8212
  • Loc: USA
  • Status: Offline

Post October 14th, 2007, 7:32 pm

is that in the .htaccess ?
"Bring forth therefore fruits meet for repentance:" Matthew 3:8

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 30 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.