Apache URL rewriting cant seem to rewrite to directory

  • aot2002
  • Born
  • Born
  • aot2002
  • Posts: 3

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • aot2002
  • Born
  • Born
  • aot2002
  • Posts: 3

Post 3+ Months Ago

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
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

is that in the .htaccess ?

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 16 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
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.